chore: make a post on discord on every release#1330
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds a GitHub Actions job that runs after a successful release, computes the release version and changelog from git, formats a multi-line message, JSON-encodes it, and posts it to a Discord webhook. Changes
Sequence Diagram(s)sequenceDiagram
participant GH as "GitHub Actions (runner)"
participant Git as "git (repo)"
participant Discord as "Discord Webhook (external)"
rect rgba(135,206,235,0.5)
GH->>Git: checkout (fetch-depth:0) and read GITHUB_REF
Git-->>GH: tags, commits
end
rect rgba(144,238,144,0.5)
GH->>GH: compute VERSION, determine PREV_TAG or last 20 commits\ngenerate CHANGELOG (exclude '- Release ' lines)
end
rect rgba(255,182,193,0.5)
GH->>Discord: POST JSON payload (version, changelog, upgrade cmd, release URL)
Discord-->>GH: 2xx/4xx response
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/release-CI.yml (2)
235-239: Good use ofjqfor JSON encoding andcurl -ffor error detection.Using
jqproperly handles special characters and newlines in the message. The-fflag ensures the step fails on HTTP errors.Consider adding
-sSflags to suppress progress output while still showing errors:♻️ Suggested improvement
- curl -f -H "Content-Type: application/json" \ + curl -fsSL -H "Content-Type: application/json" \ -d "$PAYLOAD" \ "$DISCORD_WEBHOOK_URL"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release-CI.yml around lines 235 - 239, The curl invocation that posts PAYLOAD to $DISCORD_WEBHOOK_URL should include the silent-with-errors flags so progress output is suppressed but errors are still shown; update the curl command that currently uses -f to add -sS (i.e., combine with -f) when sending the -d "$PAYLOAD" for the MESSAGE to keep logs clean while preserving failure detection.
212-214: Consider usingactions/checkout@v4.Static analysis flags
actions/checkout@v3as outdated. While this is consistent with other checkout actions in the file, you may want to update to v4 for the new job (and consider updating the others in a separate PR).♻️ Suggested update
- uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release-CI.yml around lines 212 - 214, Update the checkout step that currently uses actions/checkout@v3 to actions/checkout@v4; locate the job step where the YAML contains "uses: actions/checkout@v3" and change the version string to "@v4" (leave the with: fetch-depth: 0 intact), and consider leaving a comment or note if you plan to update other checkout usages in separate PRs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release-CI.yml:
- Around line 219-221: Validate and guard the tag extraction and log range:
ensure VERSION is only set from GITHUB_REF when it starts with "refs/tags/v"
(otherwise derive a fallback like the latest tag via git describe --tags
--abbrev=0 or a default), make PREV_TAG assignment robust by falling back when
no second tag exists (e.g., set PREV_TAG to the repository root commit via git
rev-list --max-parents=0 HEAD or leave it empty but handle that case), and when
computing CHANGELOG use a safe git log range (if PREV_TAG is empty use git log
--pretty=format:"- %s" --no-merges HEAD or use "${PREV_TAG}..HEAD" only when
PREV_TAG is non-empty) so VERSION, PREV_TAG and CHANGELOG commands handle
first-release and manual workflow_dispatch scenarios without failing.
---
Nitpick comments:
In @.github/workflows/release-CI.yml:
- Around line 235-239: The curl invocation that posts PAYLOAD to
$DISCORD_WEBHOOK_URL should include the silent-with-errors flags so progress
output is suppressed but errors are still shown; update the curl command that
currently uses -f to add -sS (i.e., combine with -f) when sending the -d
"$PAYLOAD" for the MESSAGE to keep logs clean while preserving failure
detection.
- Around line 212-214: Update the checkout step that currently uses
actions/checkout@v3 to actions/checkout@v4; locate the job step where the YAML
contains "uses: actions/checkout@v3" and change the version string to "@v4"
(leave the with: fetch-depth: 0 intact), and consider leaving a comment or note
if you plan to update other checkout usages in separate PRs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 24e81fd7-2f64-4929-bafa-cdf58c1fc127
📒 Files selected for processing (1)
.github/workflows/release-CI.yml
- Skip notification when GITHUB_REF is not a tag (e.g. workflow_dispatch) to avoid producing a nonsensical version string - Fall back to last 20 commits when PREV_TAG is empty (first release) to avoid git log failing on an invalid "..HEAD" range Made-with: Cursor
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/release-CI.yml (2)
212-214: Updateactions/checkoutto v4.The static analysis tool flags
actions/checkout@v3as outdated. Version 3 uses Node.js 16, which GitHub has been deprecating. Since this is new code, preferactions/checkout@v4which uses Node.js 20.♻️ Proposed fix
- - uses: actions/checkout@v3 + - uses: actions/checkout@v4Note: The existing checkout actions elsewhere in this workflow (lines 24, 59, 89, 126) also use v3 and could be updated in a separate PR.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release-CI.yml around lines 212 - 214, Replace uses: actions/checkout@v3 with uses: actions/checkout@v4 in the workflow steps that currently call actions/checkout (the occurrences that include the fetch-depth: 0 option), ensuring you only change the version string to v4 and preserve existing inputs like fetch-depth; update each checkout step in this file to v4 so the action runs on Node.js 20.
247-249: Consider adding a timeout to prevent indefinite hangs.While unlikely for Discord webhooks, adding a timeout ensures the job fails gracefully if the endpoint is unresponsive.
♻️ Proposed fix
- curl -f -H "Content-Type: application/json" \ + curl -f --max-time 30 -H "Content-Type: application/json" \ -d "$PAYLOAD" \ "$DISCORD_WEBHOOK_URL"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release-CI.yml around lines 247 - 249, Add a timeout to the curl call that posts $PAYLOAD to $DISCORD_WEBHOOK_URL to avoid indefinite hangs: update the curl invocation (the lines using curl -f -H "Content-Type: application/json" -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL") to include connection and overall timeouts (e.g. --connect-timeout and --max-time) so the step fails fast if Discord is unresponsive; keep -f so curl still returns a non-zero exit code on HTTP errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/release-CI.yml:
- Around line 212-214: Replace uses: actions/checkout@v3 with uses:
actions/checkout@v4 in the workflow steps that currently call actions/checkout
(the occurrences that include the fetch-depth: 0 option), ensuring you only
change the version string to v4 and preserve existing inputs like fetch-depth;
update each checkout step in this file to v4 so the action runs on Node.js 20.
- Around line 247-249: Add a timeout to the curl call that posts $PAYLOAD to
$DISCORD_WEBHOOK_URL to avoid indefinite hangs: update the curl invocation (the
lines using curl -f -H "Content-Type: application/json" -d "$PAYLOAD"
"$DISCORD_WEBHOOK_URL") to include connection and overall timeouts (e.g.
--connect-timeout and --max-time) so the step fails fast if Discord is
unresponsive; keep -f so curl still returns a non-zero exit code on HTTP errors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7ef217b8-f7e8-44cb-a744-200cdfc537ff
📒 Files selected for processing (1)
.github/workflows/release-CI.yml
Description
This PR fixes #
Summary
This PR does....
PR Checklist
Please ensure that:
Pre-Commit Instructions:
Summary by CodeRabbit