diff --git a/.github/workflows/alert-on-failed-automerge.yml b/.github/workflows/alert-on-failed-automerge.yml new file mode 100644 index 0000000000000..af9fde9675ed4 --- /dev/null +++ b/.github/workflows/alert-on-failed-automerge.yml @@ -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 diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml index 21764de0be121..9d5c7004ab990 100644 --- a/.github/workflows/build-and-deploy-prod.yml +++ b/.github/workflows/build-and-deploy-prod.yml @@ -1,4 +1,4 @@ -name: Notify Sentry and Slack +name: Notify Sentry # # Comment the `on:` section below if you want to stop deploys