Skip to content

Commit 072197c

Browse files
committed
discord release notification
1 parent 0dad0cf commit 072197c

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Discord Release Notification
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
notify-discord:
9+
name: Send Discord Notification
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Send Discord Webhook
14+
run: |
15+
# Prepare the Discord embed
16+
RELEASE_NAME="${{ github.event.release.name }}"
17+
RELEASE_TAG="${{ github.event.release.tag_name }}"
18+
RELEASE_URL="${{ github.event.release.html_url }}"
19+
RELEASE_BODY="${{ github.event.release.body }}"
20+
RELEASE_AUTHOR="${{ github.event.release.author.login }}"
21+
RELEASE_AVATAR="${{ github.event.release.author.avatar_url }}"
22+
RELEASE_DATE="${{ github.event.release.published_at }}"
23+
REPO_NAME="${{ github.repository }}"
24+
25+
# Truncate body if too long (Discord limit is 4096 characters for description)
26+
TRUNCATED_BODY=$(echo "$RELEASE_BODY" | head -c 2000)
27+
if [ ${#RELEASE_BODY} -gt 2000 ]; then
28+
TRUNCATED_BODY="${TRUNCATED_BODY}...\n\n[Read more]($RELEASE_URL)"
29+
fi
30+
31+
# Escape special characters for JSON
32+
TRUNCATED_BODY=$(echo "$TRUNCATED_BODY" | jq -Rs .)
33+
RELEASE_NAME=$(echo "$RELEASE_NAME" | jq -Rs .)
34+
35+
# Create Discord webhook payload
36+
PAYLOAD=$(cat <<EOF
37+
{
38+
"username": "GitHub Release Bot",
39+
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
40+
"embeds": [
41+
{
42+
"title": "🚀 New Release: $RELEASE_TAG",
43+
"description": $TRUNCATED_BODY,
44+
"url": "$RELEASE_URL",
45+
"color": 5814783,
46+
"fields": [
47+
{
48+
"name": "📦 Version",
49+
"value": "$RELEASE_TAG",
50+
"inline": true
51+
},
52+
{
53+
"name": "👤 Author",
54+
"value": "$RELEASE_AUTHOR",
55+
"inline": true
56+
},
57+
{
58+
"name": "📚 Repository",
59+
"value": "[$REPO_NAME](https://github.com/$REPO_NAME)",
60+
"inline": false
61+
},
62+
{
63+
"name": "📥 Installation",
64+
"value": "\`\`\`bash\nnpm install -g claude-code-templates\n# or with npx\nnpx claude-code-templates@latest --help\n\`\`\`",
65+
"inline": false
66+
}
67+
],
68+
"footer": {
69+
"text": "GitHub Release Notification",
70+
"icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
71+
},
72+
"timestamp": "$RELEASE_DATE",
73+
"thumbnail": {
74+
"url": "$RELEASE_AVATAR"
75+
}
76+
}
77+
]
78+
}
79+
EOF
80+
)
81+
82+
# Send webhook
83+
curl -H "Content-Type: application/json" \
84+
-d "$PAYLOAD" \
85+
"${{ secrets.DISCORD_WEBHOOK_URL }}"
86+
87+
- name: Verify notification
88+
run: |
89+
echo "✅ Discord notification sent successfully!"
90+
echo "Release: ${{ github.event.release.tag_name }}"
91+
echo "URL: ${{ github.event.release.html_url }}"

0 commit comments

Comments
 (0)