Skip to content

Commit

Permalink
chore: dry run of alert on automerge failure (#24935)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Sep 16, 2024
1 parent cdd529c commit c808518
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/alert-on-failed-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check Suite Failure Notification

on:
# whenever a workflow suite completes trigger this
check_suite:
types:
- completed

jobs:
notify_on_failure:
if: ${{ github.event.check_suite.conclusion == 'failure' }}
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Check if the PR has "automerge" label
id: automerge_check
run: |
pr_number=$(jq -r '.check_suite.pull_requests[0].number' <<< "${{ toJson(github.event) }}")
if [ -z "$pr_number" ]; then
echo "No PR associated with this check suite."
echo "::set-output name=result::false"
exit 0
fi
labels=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/$pr_number/labels)
echo "Labels: $labels"
if echo "$labels" | grep -q "automerge"; then
echo "::set-output name=result::true"
else
echo "::set-output name=result::false"
fi
- name: Send Slack notification if the PR has "automerge" label
if: ${{ steps.automerge_check.outputs.result == 'true' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: subscriptions-slack-testing
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/posthog.png?size=48
SLACK_USERNAME: Max Hedgehog
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
message: "PR #${{ github.event.check_suite.pull_requests[0].number }} failed a check suite and is labeled 'automerge'. Please investigate!"
status: failure
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Notify Sentry and Slack
name: Notify Sentry

#
# Comment the `on:` section below if you want to stop deploys
Expand Down

0 comments on commit c808518

Please sign in to comment.