-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (43 loc) · 1.6 KB
/
notify-on-failure.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
name: Notify on Failure
"on":
workflow_run:
workflows:
- Build and Push Images on Tags
- Release Prefect Operator Helm Chart
- Updatecli Dependency Updates
types: [completed]
permissions: {}
jobs:
notify:
name: Notify on Failure
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
permissions:
# required to introspect the workflow run
actions: read
# required to read from the repo
contents: read
steps:
- name: Format date
run: |
formatted_date=$(date -d "${{ github.event.workflow_run.run_started_at }}" "+%b %d at %I:%M %p")
echo "FORMATTED_DATE=$formatted_date" >> $GITHUB_ENV
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: custom
# https://api.slack.com/reference/messaging/attachments
custom_payload: |
{
attachments: [{
pretext: ':x: Workflow triggered by ${{ github.actor }} failed',
title: '${{ github.event.workflow_run.display_title }} #${{github.event.workflow_run.run_number}}',
title_link: '${{ github.event.workflow_run.html_url }}',
footer: '${{ github.repository }} | ${{ env.FORMATTED_DATE }} UTC',
footer_icon: 'https://slack-imgs.com/?c=1&o1=wi32.he32.si&url=https%3A%2F%2Fslack.github.com%2Fstatic%2Fimg%2Ffavicon-neutral.png',
color: 'danger',
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_GHA_JOB_STATUS }}