Skip to content

Commit 2786e6e

Browse files
lennessyyDuncanma
andauthored
ci: alert Slack when non-PR workflows fail (#5027)
Adds a workflow_run listener that posts to Slack when one of the seven non-PR workflows ends in failure, timed_out, or startup_failure. PR CI failures are excluded since they surface on the pull request itself. Requires the SLACK_AUTOMATION_ALERTS_WEBHOOK repository secret. Co-authored-by: Duncan Mackenzie <duncanma@duncanmackenzie.net>
1 parent 87cc183 commit 2786e6e

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Notify Automation Failures
2+
3+
# Posts to Slack when a non-PR workflow fails. PR CI failures are surfaced on the
4+
# pull request itself and are deliberately excluded here.
5+
#
6+
# The `workflows` list below uses each workflow's `name:` value, not its filename.
7+
# Renaming a workflow silently stops matching it, so update this list alongside
8+
# any rename.
9+
10+
on:
11+
workflow_run:
12+
workflows:
13+
- Snipsync
14+
- Screenshot Capture
15+
- Update Custom Role Permissions
16+
- Check Metrics Against SDKs
17+
- CLI Docs Update
18+
- Delete Visual Tests Reports
19+
- Warm Build Cache
20+
types:
21+
- completed
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
notify:
28+
# `Check Metrics Against SDKs` also runs on pull_request; exclude those runs so
29+
# this only reports the scheduled invocation.
30+
if: >-
31+
github.event.workflow_run.event != 'pull_request' &&
32+
contains(fromJSON('["failure", "timed_out", "startup_failure"]'), github.event.workflow_run.conclusion)
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Post failure to Slack
36+
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
37+
with:
38+
webhook: ${{ secrets.SLACK_AUTOMATION_ALERTS_WEBHOOK }}
39+
webhook-type: incoming-webhook
40+
payload: |
41+
text: "${{ github.event.workflow_run.name }} ${{ github.event.workflow_run.conclusion }} on ${{ github.repository }}"
42+
blocks:
43+
- type: section
44+
text:
45+
type: mrkdwn
46+
text: "*${{ github.event.workflow_run.name }}* ${{ github.event.workflow_run.conclusion }}\n<${{ github.event.workflow_run.html_url }}|Run #${{ github.event.workflow_run.run_number }}> · triggered by `${{ github.event.workflow_run.event }}` · branch `${{ github.event.workflow_run.head_branch }}`"

0 commit comments

Comments
 (0)