chore: add alerts for push failures in sync release to pg flow (#37355)

This commit is contained in:
Anagh Hegde 2024-11-13 11:13:07 +05:30 committed by GitHub
parent f8f3edc8fc
commit c18d521409
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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'