Skip to content

Discord Github PR Notification#259

Merged
namanlp merged 2 commits into
codenet:mainfrom
Yash-Rawat-IIT-D:main-discord-int
Mar 18, 2026
Merged

Discord Github PR Notification#259
namanlp merged 2 commits into
codenet:mainfrom
Yash-Rawat-IIT-D:main-discord-int

Conversation

@Yash-Rawat-IIT-D

Copy link
Copy Markdown
Contributor

Add Discord Notifications for PR Merges

Summary

This PR introduces a GitHub Actions workflow and a lightweight Python script to send notifications to Discord when pull requests are merged.

Motivation

The repository contains multiple target branches (p1-*, p2-*, …), and PRs may target any of them. Maintaining separate workflows across all branches would be difficult and error-prone.
This change centralizes automation in a single place and provides visibility into merge activity via Discord.


Key Design Choices

1. Use of pull_request_target

  • The workflow is triggered using:

    pull_request_target:
      types: [closed]
  • This ensures:

    • The workflow is always loaded from the default branch (main)
    • No need to duplicate .github/workflows across all pX-* branches

2. Filter only merged PRs

  • The closed event includes both merged and non-merged PRs

  • Filtering is handled in scripts/notify.py:

    • Only merged PRs generate notifications

3. Python-based notification logic

  • All formatting and routing logic is implemented in scripts/notify.py
  • This avoids complex YAML scripting and makes future extensions easier

4. Discord Webhook Integration

  • Uses repository secret:

    DISCORD_WEBHOOK
    
  • Sends structured messages (embed format) to the configured Discord channel (#pr-merges)


Features (Initial Scope)

  • Notify when a PR is merged

  • Include:

    • PR title
    • PR number
    • Author
    • Target branch
    • Direct link to PR
  • Clean embed-based formatting for readability


Files Added

.github/workflows/discord.yml   # Workflow definition
scripts/notify.py              # Notification logic

Testing

  • Tested via push events on a personal repository

  • Verified:

    • Webhook delivery
    • Embed formatting
    • Environment variable handling

Future Improvements

  • Notifications for:

    • PR comments
    • PR reviews
  • Label-based routing (e.g., errata vs development)

  • Multiple Discord channels

  • Improved formatting (icons, richer embeds)


Notes

  • No existing functionality is modified
  • Safe usage of pull_request_target (no execution of untrusted PR code)
  • Minimal, incremental rollout for easier review

Expected Outcome

Once merged, all future PR merges (to any pX-* branch) will automatically trigger a Discord notification without requiring additional configuration.

@namanlp namanlp merged commit 768061d into codenet:main Mar 18, 2026
@sai-kaushik-s sai-kaushik-s added Spring2026 PR made be Spring 2026 students, possibly for errata participation. Misc bug/fix Fix something that is not working. and removed Misc labels May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug/fix Fix something that is not working. Spring2026 PR made be Spring 2026 students, possibly for errata participation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants