Skip to content

Commit c5be69d

Browse files
julianknutsenclaude
andcommitted
feat: show all commits in Discord deploy notification
List every commit between the previous and new production tip instead of just the HEAD commit. Capped at 15 entries with overflow count. Uses jq for safe JSON escaping of commit messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 372c814 commit c5be69d

1 file changed

Lines changed: 43 additions & 16 deletions

File tree

.github/workflows/deploy-notify.yml

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,55 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v6
1313
with:
14-
fetch-depth: 2
14+
fetch-depth: 0
1515

16-
- name: Get commit info
16+
- name: Build commit summary
1717
id: info
1818
run: |
19-
echo "short_sha=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
20-
echo "message=$(git log -1 --pretty=%s)" >> "$GITHUB_OUTPUT"
21-
echo "author=$(git log -1 --pretty=%an)" >> "$GITHUB_OUTPUT"
19+
# Compare against the previous production tip (before this push)
20+
BEFORE="${{ github.event.before }}"
21+
HEAD="${{ github.sha }}"
22+
SHORT_HEAD="$(git rev-parse --short HEAD)"
23+
24+
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
25+
# First push to production — just show the HEAD commit
26+
LOG="$(git log -1 --pretty='• \`%h\` %s (%an)')"
27+
COUNT=1
28+
else
29+
COUNT="$(git rev-list --count "${BEFORE}..${HEAD}")"
30+
LOG="$(git log --pretty='• \`%h\` %s (%an)' "${BEFORE}..${HEAD}" | head -15)"
31+
if [ "$COUNT" -gt 15 ]; then
32+
LOG="${LOG}
33+
…and $((COUNT - 15)) more"
34+
fi
35+
fi
36+
37+
# Write multiline output
38+
{
39+
echo "log<<DELIM"
40+
echo "$LOG"
41+
echo "DELIM"
42+
} >> "$GITHUB_OUTPUT"
43+
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
44+
echo "short_sha=$SHORT_HEAD" >> "$GITHUB_OUTPUT"
2245

2346
- name: Notify Discord
2447
env:
2548
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
2649
run: |
27-
curl -fsSL -H "Content-Type: application/json" -d "{
28-
\"embeds\": [{
29-
\"title\": \"Wasteland deployed to production\",
30-
\"description\": \"\`${{ steps.info.outputs.short_sha }}\` ${{ steps.info.outputs.message }}\",
31-
\"color\": 5025616,
32-
\"fields\": [
33-
{\"name\": \"Author\", \"value\": \"${{ steps.info.outputs.author }}\", \"inline\": true},
34-
{\"name\": \"Branch\", \"value\": \"production\", \"inline\": true}
50+
jq -n \
51+
--arg title "Wasteland deployed to production" \
52+
--arg desc "${{ steps.info.outputs.log }}" \
53+
--arg count "${{ steps.info.outputs.count }} commit(s)" \
54+
--arg sha "${{ steps.info.outputs.short_sha }}" \
55+
--arg url "https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.sha }}" \
56+
'{embeds: [{
57+
title: $title,
58+
description: $desc,
59+
color: 5025616,
60+
fields: [
61+
{name: "Commits", value: $count, inline: true},
62+
{name: "Head", value: ("`" + $sha + "`"), inline: true}
3563
],
36-
\"url\": \"https://github.com/${{ github.repository }}/commit/${{ github.sha }}\"
37-
}]
38-
}" "$DISCORD_WEBHOOK"
64+
url: $url
65+
}]}' | curl -fsSL -H "Content-Type: application/json" -d @- "$DISCORD_WEBHOOK"

0 commit comments

Comments
 (0)