Files
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

82 lines
3.2 KiB
YAML

name: Discord Release Notification
on:
release:
types: [published]
permissions:
contents: read
jobs:
notify-discord:
name: Send Discord Notification
runs-on: ubuntu-latest
steps:
- name: Send Discord Webhook
env:
RELEASE_NAME: ${{ github.event.release.name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
RELEASE_AUTHOR: ${{ github.event.release.author.login }}
RELEASE_AVATAR: ${{ github.event.release.author.avatar_url }}
RELEASE_DATE: ${{ github.event.release.published_at }}
RELEASE_BODY: ${{ github.event.release.body }}
REPO_NAME: ${{ github.repository }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
# Truncate body if too long (Discord limit is 4096 characters for description)
TRUNCATED_BODY=$(printf '%s' "$RELEASE_BODY" | head -c 2000)
BODY_LENGTH=$(printf '%s' "$RELEASE_BODY" | wc -c | tr -d ' ')
if [ "$BODY_LENGTH" -gt 2000 ]; then
TRUNCATED_BODY="${TRUNCATED_BODY}...\n\n[Read more](${RELEASE_URL})"
fi
# Build payload safely with jq (no shell interpolation in JSON)
PAYLOAD=$(jq -n \
--arg tag "$RELEASE_TAG" \
--arg body "$TRUNCATED_BODY" \
--arg url "$RELEASE_URL" \
--arg author "$RELEASE_AUTHOR" \
--arg repo "$REPO_NAME" \
--arg date "$RELEASE_DATE" \
--arg avatar "$RELEASE_AVATAR" \
'{
username: "GitHub Release Bot",
avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
embeds: [
{
title: ("🚀 New Release: " + $tag),
description: $body,
url: $url,
color: 5814783,
fields: [
{ name: "📦 Version", value: $tag, inline: true },
{ name: "👤 Author", value: $author, inline: true },
{ name: "📚 Repository", value: ("[\($repo)](https://github.com/\($repo))"), inline: false },
{ name: "📥 Installation", value: "```bash\nnpm install -g claude-code-templates\n# or with npx\nnpx claude-code-templates@latest --help\n```", inline: false }
],
footer: {
text: "GitHub Release Notification",
icon_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
},
timestamp: $date,
thumbnail: { url: $avatar }
}
]
}')
# Send webhook
curl -sf -H "Content-Type: application/json" \
-d "$PAYLOAD" \
"$DISCORD_WEBHOOK_URL"
- name: Verify notification
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
run: |
echo "✅ Discord notification sent successfully!"
echo "Release: $RELEASE_TAG"
echo "URL: $RELEASE_URL"