-
-
Notifications
You must be signed in to change notification settings - Fork 41
37 lines (33 loc) · 1.62 KB
/
failed-actions-notify.yml
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
name: Slack Notifications for Failed GitHub Actions
on:
workflow_run:
workflows: ["*"]
types:
- completed
branches:
- main
permissions:
actions: read
jobs:
on-failure:
runs-on: ubuntu-latest
if: |
(github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'timed_out') &&
github.event.workflow_run.name != 'Slack Notifications for Failed GitHub Actions'
timeout-minutes: 10
steps:
- name: Send Slack Notification
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ github.event.workflow_run.conclusion }}
notification_title: " ${{github.event.workflow_run.name}} - ${{github.event.workflow_run.conclusion}} on ${{github.event.workflow_run.head_branch}} - <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>"
message_format: ":fire: *${{github.event.workflow_run.name}}* ${{github.event.workflow_run.conclusion}} in <${{github.server_url}}/${{github.repository}}/${{github.event.workflow_run.head_branch}}|${{github.repository}}>"
footer: "Linked Repo <${{github.server_url}}/${{github.repository}}|${{github.repository}}> | <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_WORKFLOW_NOTIF }}
- name: Check Slack Notification Status
if: failure()
run: |
echo "Failed to send Slack notification"
echo "Workflow Run ID: ${{ github.event.workflow_run.id }}"