-
Notifications
You must be signed in to change notification settings - Fork 3
41 lines (39 loc) · 1.36 KB
/
notify_failure.yml
File metadata and controls
41 lines (39 loc) · 1.36 KB
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
name: Discord Failure Notification
on:
workflow_run:
workflows:
- "Check for Crowdin Updates"
- "Test Failure Notification"
types:
- completed
jobs:
notify:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Send Discord notification
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_ROLE_ID: ${{ secrets.DISCORD_ROLE_ID }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
run: |
if [ "$WORKFLOW_NAME" = "Test Failure Notification" ]; then
FLAGS=4096
else
FLAGS=0
fi
curl -H "Content-Type: application/json" \
-d '{
"content": "<@&'"$DISCORD_ROLE_ID"'> ⚠️ GitHub Action failed!",
"flags": '"$FLAGS"',
"embeds": [{
"title": "Workflow Failed: '"$WORKFLOW_NAME"'",
"url": "${{ github.event.workflow_run.html_url }}",
"color": 15158332,
"fields": [
{"name": "Repository", "value": "${{ github.repository }}", "inline": true},
{"name": "Branch", "value": "${{ github.event.workflow_run.head_branch }}", "inline": true}
]
}]
}' \
"$DISCORD_WEBHOOK_URL"