Instead of having a single Discord channel for all your GitHub repository feeds, or having a separate tech channel for each repository, you can use this worker to create a forum post for each repository and sort your GitHub activity into those forum posts individually. This way, you can have a single channel for all your GitHub activity, but still keep it organized by repository - and users can easily follow the forum posts that they are interested in.
Screenshot

- Deploy to Cloudflare Workers using the button above. It should be as simple as keeping all defaults, unless you want to change some predefined variables.
- Insert the two variable secrets, either via the Cloudflare Workers dashboard (recommended) or using the command
wrangler secret put <key>
:GITHUB_WEBHOOK_SECRET
- your secret for webhooks (like a phrase or a word) to verify that the webhook is coming from GitHub. This needs to match the secret you set in your GitHub webhook settings.DISCORD_WEBHOOK
- your Discord webhook link (needs to be in a forum channel!). The link should not end in/github
as the worker will append that automatically.
- Add your new worker URL (
https://gitcord-forum.WORKER_SUBDOMAIN.workers.dev/
) as a webhook in your GitHub repository settings with your preferred set of notifications to get from the repository. Make sure to set content type toapplication/json
and also match the secret you set in the environment variables.- Make sure that the
repository
event is enabled. Although not supported by Discord, it is recommended to enable updates to the first message in the forum channel. - You can also add this URL as a webhook for your entire GitHub organization!
- Make sure that the
Keep in mind that the worker will simply forward the GitHub events to Discord, so you will make sure that Discord has support for the events you want to pass through. See Discord's documentation for a list of supported events. The worker will automatically ignore events that are not supported by Discord, and will rather use these events to update the first message in the forum channel with the latest information about the repository. We therefore recommend enabling the repository
event in your webhook settings, so it can get infrequent updates about the repository.
sequenceDiagram
autonumber
participant G as GitHub
participant W as Cloudflare Worker & Storage
participant D as Discord Webhook
activate G
G->>W: Send a Webhook event
activate W
alt signature header is not valid
W->>G: 401 Unauthorized
end
alt event is ignored in some way, e.g. if it's not from a repository or is from a sender which is ignored
W->>G: 202 Accepted "GitHub event ignored"
end
W->>W: Find thread ID for repository
alt no forum thread exists
W->>D: Create a new forum thread and send first message
D->>W: Return message data with thread ID
W->>W: Save thread ID and message ID
else forum thread exists
W->>D: Update first forum message with new information
end
W->>D: Forward GitHub event to new or existing forum thread
D->>W: Response back from Discord including the rate limit headers
W->>G: Passthrough Discord's response