diff --git a/.github/workflows/sync-release-to-pg.yml b/.github/workflows/sync-release-to-pg.yml index b5bd192f597d..a962d28c9e2d 100644 --- a/.github/workflows/sync-release-to-pg.yml +++ b/.github/workflows/sync-release-to-pg.yml @@ -50,7 +50,36 @@ jobs: - name: Push changes if: env.MERGE_CONFLICT == 'false' run: | - git push origin pg + set -e + git push origin pg || echo "PUSH_FAILURE=true" >> $GITHUB_ENV + + - name: Capture push failure message + if: env.PUSH_FAILURE == 'true' + run: | + # Capture the last git error message + push_error_message=$(git push origin pg 2>&1 | tail -n 1) + echo "PUSH_ERROR_MESSAGE=$push_error_message" >> $GITHUB_ENV + + - name: Notify on push failure + if: env.PUSH_FAILURE == 'true' + env: + SLACK_MESSAGE: "Push to pg branch failed: ${{ env.PUSH_ERROR_MESSAGE }}" + run: | + # Format the Slack message + slack_message="${{ env.SLACK_MESSAGE }}" + + # Set the Slack message body with channel ID and text + body="$(jq -nc \ + --arg channel C07JMLWEXDJ \ + --arg text "$slack_message" \ + '$ARGS.named' + )" + + # Send the message to Slack + curl -v https://slack.com/api/chat.postMessage \ + --header "Authorization: Bearer ${{ secrets.SLACK_APPSMITH_ALERTS_TOKEN }}" \ + --header "Content-Type: application/json; charset=utf-8" \ + --data-raw "$body" - name: Notify on merge conflicts if: env.MERGE_CONFLICT == 'true'