Skip to content

Refactor Discord webhook URL handling in workflow#461

Merged
siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
imAaryash:discord-actions
Apr 18, 2026
Merged

Refactor Discord webhook URL handling in workflow#461
siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
imAaryash:discord-actions

Conversation

@imAaryash
Copy link
Copy Markdown
Collaborator

@imAaryash imAaryash commented Apr 16, 2026

small update

Summary by CodeRabbit

  • Chores
    • Enhanced Discord webhook configuration to support multiple environment variable options for improved flexibility.
    • Improved fork pull request handling to gracefully skip Discord notifications instead of failing the workflow.
    • Updated error messaging to provide clearer guidance when webhook configuration is missing.

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

Workflow 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

Cohort / File(s) Summary
Discord Webhook Handling
.github/workflows/discord.yaml
Exposed both DISCORD_WEBHOOK_URL and DISCORD_PR_FORUM_WEBHOOK to job environment. Updated webhook resolution to prefer primary secret with fallback. Added fork PR detection to skip syncing rather than fail. Deferred error handling until after loading PR context, with updated error message listing both supported secret options.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • siddharthvaddem/openscreen#452: Both PRs modify the Discord webhook workflow; this PR builds on top with additional fallback logic and fork-handling behavior.

Suggested reviewers

  • siddharthvaddem

Poem

🪝 webhooks dancing in the dark,
forks skip by without a spark,
fallbacks catch what primary missed—
2am logic, lowkey blessed ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete. It only contains 'small update' without following the repository template structure (missing Description, Motivation, Type of Change, Related Issues, Testing sections). Expand description to include: what the change does, why it's needed, which type of change it is, any related issues, and how to test it.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Refactor Discord webhook URL handling in workflow' accurately describes the main change - improving webhook URL selection and validation logic in the workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/discord.yaml (1)

203-213: fork detection works but has a subtle edge case

pr.head.repo.fork checks 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d449a4 and 7264b99.

📒 Files selected for processing (1)
  • .github/workflows/discord.yaml

@siddharthvaddem siddharthvaddem merged commit e85d07b into siddharthvaddem:main Apr 18, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants