Skip to content

A middleware designed to sort your repository feeds into Discord forum posts. Built with Cloudflare Workers

License

Notifications You must be signed in to change notification settings

biaw/gitcord-forum

Repository files navigation

Image of the forum channel on Discord

Explanation

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 Image of the forum channel on Discord

Setting up with Cloudflare Workers

Deploy to Cloudflare Workers

  1. Deploy to Cloudflare Workers using the button above.
  2. Insert the environment variables listed in the wrangler.toml file. You can either use the wrangler command, or do it through the worker dashboard.
  3. 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 to application/json and also match the secret you set in the environment variables.
    • You can also add this URL as a webhook for your entire GitHub organization!

How the middleware works

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 not a repository event
        W->>G: 200 OK
    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
    W->>G: 200 OK
Loading

About

A middleware designed to sort your repository feeds into Discord forum posts. Built with Cloudflare Workers

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 2

  •  
  •