Skip to content

Commit f6b5d85

Browse files
Update GitHub Actions to notify Discord with commits
1 parent f7d042f commit f6b5d85

File tree

1 file changed

+22
-41
lines changed

1 file changed

+22
-41
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,25 @@ on:
77
jobs:
88
notify:
99
runs-on: ubuntu-latest
10-
steps:
11-
- name: Actions Status Discord
12-
# You may pin to the exact commit or the version.
13-
# uses: sarisia/actions-status-discord@11a0bfe3b50977e38aa2bd4a4ebd296415e83c19
14-
uses: sarisia/[email protected]
15-
with:
16-
# Discord webhook endpoint. If not set, env.DISCORD_WEBHOOK will be used.
17-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
18-
# Job status. Should be bound to job.status. Default to success.
19-
#status: # optional, default is ${{ job.status }}
20-
# Deprecated. Job name included in message title. Same as title input.
21-
#job: # optional
22-
# Content. Shown as an message outside of the embed. See [Mention to user/role](#mention-to-user-role)
23-
#content: # optional
24-
# String included in embed title. Overrides job input.
25-
title: "New push"
26-
# Description included in message
27-
#description: # optional
28-
# Image attached to the message
29-
#image: # optional
30-
# Overrides Discord embed color
31-
#color: # optional
32-
# URL to jump when the title is clicked
33-
#url: # optional
34-
# Overrides Discord webhook username
35-
#username: # optional
36-
# Overrides Discord webhook avatar url
37-
#avatar_url: # optional
38-
# This action won't make workflow failed by default.
39-
#nofail: # optional, default is true
40-
# Suppress GitHub context fields
41-
#nocontext: # optional, default is false
42-
# Avoid appending job status to title
43-
noprefix: true
44-
# Suppress detailed embed fields
45-
nodetail: true
46-
# Avoid appending timestamp
47-
#notimestamp: # optional, default is false
48-
# Suppress error which raised when webhook is not set
49-
#ack_no_webhook: # optional, default is false
50-
10+
steps:
11+
- name: Build commit list
12+
id: commits
13+
run: |
14+
COMMIT_TEXT=""
15+
for commit in $(jq -c '.commits[]' < "${GITHUB_EVENT_PATH}"); do
16+
MSG=$(echo "$commit" | jq -r '.message')
17+
URL=$(echo "$commit" | jq -r '.url')
18+
COMMIT_TEXT="${COMMIT_TEXT}- [$MSG]($URL)"
19+
done
20+
echo "commit_text<<EOF" >> $GITHUB_OUTPUT
21+
echo "$COMMIT_TEXT" >> $GITHUB_OUTPUT
22+
echo "EOF" >> $GITHUB_OUTPUT
23+
24+
- name: Send commits to Discord
25+
uses: sarisia/[email protected]
26+
with:
27+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
28+
title: "New push to ${{ github.ref_name }}"
29+
description: "${{ steps.commits.outputs.commit_text }}"
30+
noprefix: true
31+
nocontext: true

0 commit comments

Comments
 (0)