Refactor Discord webhook URL handling in workflow#461
Refactor Discord webhook URL handling in workflow#461siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
Conversation
Updated Discord webhook handling to allow for a fallback to DISCORD_PR_FORUM_WEBHOOK if DISCORD_WEBHOOK_URL is not set. Added checks to ensure webhook URL is provided, especially for fork PR events.
📝 WalkthroughWalkthroughWorkflow now exposes both Discord webhook environment variables and implements smarter resolution logic. Fork PRs skip webhook syncing instead of failing, and error handling defers until PR context is loaded. Webhook resolution prefers the primary secret but falls back gracefully. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
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. 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.
🧹 Nitpick comments (1)
.github/workflows/discord.yaml (1)
203-213: fork detection works but has a subtle edge case
pr.head.repo.forkchecks if the head repo is any fork, not specifically if it's a cross-repo PR. in practice this usually works, but it could give false positives if someone PRs from a branch in their own repo that happens to be a fork of something unrelated.a more precise check would be comparing repo full names:
const isForkPr = pr.head?.repo?.full_name !== pr.base?.repo?.full_name;that said, the current approach is probably fine for most workflows - just something to keep in mind if you see weird skips.
🔧 optional: more precise fork detection
- const isForkPr = !!pr.head?.repo?.fork; + const isForkPr = pr.head?.repo?.full_name !== pr.base?.repo?.full_name;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/discord.yaml around lines 203 - 213, Replace the broad fork check that uses pr.head?.repo?.fork with a comparison of repository full names to detect cross-repo PRs more precisely: change the isForkPr assignment from using pr.head?.repo?.fork to using pr.head?.repo?.full_name !== pr.base?.repo?.full_name (keep the optional chaining as in pr.head?.repo?.full_name and pr.base?.repo?.full_name to avoid runtime errors), so downstream logic that skips webhook handling only triggers for true cross-repo PRs.
🤖 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/discord.yaml:
- Around line 203-213: Replace the broad fork check that uses
pr.head?.repo?.fork with a comparison of repository full names to detect
cross-repo PRs more precisely: change the isForkPr assignment from using
pr.head?.repo?.fork to using pr.head?.repo?.full_name !==
pr.base?.repo?.full_name (keep the optional chaining as in
pr.head?.repo?.full_name and pr.base?.repo?.full_name to avoid runtime errors),
so downstream logic that skips webhook handling only triggers for true
cross-repo PRs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 35b188db-3746-4872-b398-1be74a41257b
📒 Files selected for processing (1)
.github/workflows/discord.yaml
small update
Summary by CodeRabbit