Skip to content

Commit dff41b1

Browse files
Add Discord push notification workflow
This workflow sends push notifications to Discord with commit details.
1 parent 29c6ad5 commit dff41b1

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Discord Push Notifications
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
notify:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Build commit list
12+
id: commits
13+
run: |
14+
COMMIT_TEXT=""
15+
while read commit; do
16+
MSG=$(echo "$commit" | jq -r '.message')
17+
URL=$(echo "$commit" | jq -r '.url')
18+
19+
# Skip commits starting with "Merge branch"
20+
if [[ "$MSG" == Merge\ branch* ]]; then
21+
continue
22+
fi
23+
24+
COMMIT_TEXT="${COMMIT_TEXT}- [$MSG]($URL)
25+
"
26+
done < <(jq -c '.commits[]' < "${GITHUB_EVENT_PATH}")
27+
28+
# Write output for later steps
29+
echo "commit_text<<EOF" >> $GITHUB_OUTPUT
30+
echo "$COMMIT_TEXT" >> $GITHUB_OUTPUT
31+
echo "EOF" >> $GITHUB_OUTPUT
32+
33+
- name: Send commits to Discord
34+
uses: sarisia/actions-status-discord@v1.15.4
35+
with:
36+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
37+
title: "New Update"
38+
description: |
39+
**New push to ${{ github.ref_name }}**
40+
${{ steps.commits.outputs.commit_text }}
41+
noprefix: true
42+
nocontext: true
43+
content: "<@&1411181618307137628>"

0 commit comments

Comments
 (0)