Skip to content

Commit 1ca3179

Browse files
committed
Update Discord workflow to include commit details on push
1 parent fce07ff commit 1ca3179

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

.github/workflows/discord-activity.yml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,41 @@ name: "Discord: repo activity"
33
on:
44
push:
55
branches: ["**"]
6-
pull_request:
7-
types:
8-
[
9-
opened,
10-
reopened,
11-
synchronize,
12-
closed,
13-
edited,
14-
converted_to_draft,
15-
ready_for_review,
16-
]
17-
issues:
18-
types: [opened, closed, edited, reopened]
19-
release:
20-
types: [published, released]
21-
workflow_dispatch:
226

237
jobs:
248
notify:
259
runs-on: ubuntu-latest
2610
steps:
27-
- name: Post to Discord
11+
- name: Build commit summary (for push)
12+
id: build
13+
run: |
14+
EVENT='${{ toJSON(github.event) }}'
15+
COUNT=$(jq -r '.commits | length' <<< "$EVENT")
16+
REF=$(jq -r '.ref' <<< "$EVENT")
17+
COMPARE=$(jq -r '.compare' <<< "$EVENT")
18+
19+
# List every commit (one line per commit)
20+
COMMITS=$(jq -r '.commits[]
21+
| "- " + (.message | gsub("\\r?\\n"; " "))
22+
+ " (" + .id[0:7] + ") by " + .author.name' <<< "$EVENT")
23+
24+
{
25+
echo "COUNT=$COUNT"
26+
echo "REF=$REF"
27+
echo "COMPARE=$COMPARE"
28+
echo 'COMMITS<<EOF'
29+
echo "$COMMITS"
30+
echo 'EOF'
31+
} >> "$GITHUB_ENV"
32+
33+
- name: Post to Discord (with full commit list)
2834
uses: Ilshidur/[email protected]
2935
env:
3036
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
31-
GITHUB_EVENT_NAME: ${{ github.event_name }}
32-
GITHUB_ACTOR: ${{ github.actor }}
33-
GITHUB_REF: ${{ github.ref }}
34-
# Optional cosmetics:
35-
# DISCORD_USERNAME: "GitHub Bot"
36-
# DISCORD_AVATAR: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
3737
with:
38-
# You can customize this message freely (supports interpolation)
3938
args: >
40-
[{{ EVENT_PAYLOAD.repository.full_name }}] {{ GITHUB_EVENT_NAME }} by {{ GITHUB_ACTOR }}
41-
• Ref: {{ GITHUB_REF }}
42-
• Link: https://github.com/{{ EVENT_PAYLOAD.repository.full_name }}
39+
[${{ github.repository }}] push by ${{ github.actor }}
40+
• Ref: ${{ env.REF }}
41+
• ${{ env.COUNT }} commit(s):
42+
${{ env.COMMITS }}
43+
• Diff: ${{ env.COMPARE }}

0 commit comments

Comments
 (0)