Files
davila7__claude-code-templates/.github/workflows/discord-release-notification.yml
Daniel Avila 0e06493dbe security: Harden CI/CD and repo for open-source safety (#458)
* enhance: Improve prompt-engineer agent (automated review)

- Fix broken reasoning framework: complete Ordering field and Necessity scale
- Remove OpenAI attribution from description; add invocation example block
- Restrict tools to Read only (text-transformation agent needs no writes)
- Add XML Structure and CoT Opportunity dimensions to reasoning template
- Move meta-instruction NOTE out of output template, place as agent directive
- Fix stray markdown bold markers on Reasoning Before Conclusions guideline
- Integrate orphaned examples bullet into the Examples guideline line
- Add concrete worked example section (classify customer feedback)

Automated review cycle | Co-Authored-By: Claude Code <noreply@anthropic.com>

* security: Harden CI/CD and repo for open-source safety

- Add --ignore-scripts to all npm ci/install in CI workflows and predeploy script
- Fix shell injection in discord-release-notification (use env vars + jq for payload)
- Add explicit permissions to all workflows (least privilege principle)
- Add root .npmrc with ignore-scripts=true
- Add .github/dependabot.yml for automated dependency security updates
- Add .github/CODEOWNERS to protect workflows, scripts, and API paths
- Expand .gitignore with *.pem, *.key, credentials.json patterns

* fix: Grant contents:read to deploy workflow so checkout works

Cubic correctly flagged that permissions: {} blocks actions/checkout.
2026-03-26 19:19:39 -04: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"