1- name : Discord Commit Notification
1+ name : Discord Notification on Push
22
33on :
44 push :
5- branches : main
5+ branches :
6+ - main
67
78jobs :
8- notify-discord :
9+ notify :
910 runs-on : ubuntu-latest
10- permissions :
11- contents : read
1211 steps :
1312 - name : Checkout repository
1413 uses : actions/checkout@v5
15- with :
16- fetch-depth : 0
17-
18- - name : Get commit and file details
19- id : commit
20- run : |
21- COMMITS_JSON=$(git log --oneline ${{ github.event.before }}..${{ github.event.after }} --format='%h%x00%an%x00%s%x00%B%x00' | jq -R -s 'split("") | map(select(. != "")) as $lines | [range(0; $lines | length; 4) as $i | $lines[$i:$i+4]] | map({sha: .[0], author: .[1], message: .[2], full_message: .[3]}) | .')
22-
23- echo "commits_json<<EOF" >> $GITHUB_OUTPUT
24- echo "$COMMITS_JSON" >> $GITHUB_OUTPUT
25- echo "EOF" >> $GITHUB_OUTPUT
26-
27- - name : Get changed files count
28- id : changed-files
29- uses : tj-actions/changed-files@v44
30- with :
31- since_last_remote_commit : true
3214
33- - name : Send Discord notification
34- uses : actions/github-script@v7
15+ - name : Set up Node.js
16+ uses : actions/setup-node@v4
3517 with :
36- script : |
37- const { sendDiscordNotification } = require('./.github/scripts/webhook.js');
38-
39- const commits = JSON.parse(process.env.COMMITS_JSON || '[]');
40- const fileCount = parseInt(process.env.FILE_COUNT || '0');
41-
42- await sendDiscordNotification(
43- process.env.DISCORD_WEBHOOK_URL,
44- commits,
45- fileCount
46- );
18+ node-version : ' 22'
4719
48- console.log(' Discord webhook posted successfully');
20+ - name : Send Discord Notification
4921 env :
5022 DISCORD_WEBHOOK_URL : ${{ secrets.DISCORD_WEBHOOK_URL }}
51- COMMITS_JSON : ${{ steps.commit.outputs.commits_json }}
52- FILE_COUNT : ${{ steps.changed-files.outputs.all_changed_files_count }}
23+ run : node .github/scripts/sendwebhook.js
0 commit comments