-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (37 loc) · 1.05 KB
/
discordmessage.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
38
39
40
41
42
name: Discord CI trigger
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: |
exit 1
- name: Notify Discord on Failure
if: failure()
run: |
COMMITTER_GITHUB=$(git show -s --format='%cn')
case "$COMMITTER_GITHUB" in
"kings177")
DISCORD_ID="353453210389839872" # My ID
;;
*)
DISCORD_ID=""
;;
esac
CI_LINK="<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}>"
if [ ! -z "$DISCORD_ID" ]; then
MESSAGE="The CI from <@$DISCORD_ID>'s commit has failed, please check: $CI_LINK"
curl -X POST ${{ secrets.DISCORD_WEBHOOK_URL }} \
-H "Content-Type: application/json" \
-d '{
"content": "'"$MESSAGE"'",
"username": "Kindelia Bot"
}'
else
echo "CI failed: $CI_LINK"
fi