GitOpsing a Discord message
In Discord communities, it’s common to create read-only channels for rules, resources, and other important information. While this information is important for community members to see, it can be difficult to manage and update if only the original poster has the ability to edit those messages.
However, by applying the principles of GitOps, it’s possible to store the message content in a GitHub repo and use GitHub Actions to update the messages on behalf of the server admin.
This means that anyone can contribute and make updates to these messages by submitting pull requests, making the process of maintaining and updating important information in Discord communities more efficient, collaborative, and transparent.
Create a webhook. You will get a webhook URL.
Send the message to the webhook URL.
# Example, using HTTPie http post "$RESOURCES_WEBHOOK_URL?wait=true" content="hello world"
Copy the message ID.
To edit the message, send a PATCH request to the message URL.
# Example, using HTTPie http patch $RESOURCES_WEBHOOK_URL/messages/$RESOURCES_MESSAGE_ID content="hello world2"
Write a script to update the message. Example
Assuming that the
$RESOURCES_WEBHOOK_URL
and$RESOURCES_MESSAGE_ID
are stored in a.env
file, we can upload them as secrets to GitHub:# Using `gh` CLI gh secret set -f .env
Write a GitHub Actions workflow to run the script when pushed. Example
Push everything to GitHub. The workflow will run and the message should be updated.
Currently being used in: