GitHub bot which helps out on Red-DiscordBot's repository.
-
Automated backports
Labeling a PR with Needs Backport To 3.x label will cause the bot to attempt to automatically backport the PR to the appropriate maintenance branch once it's merged.
-
Copy labels from the original PR to the backport
The bot copies the relevant labels (type, and some release indicators) from the original PR to the backport PR.
-
Comment on the original PR about the backport
To help find the backport PR from the original PR, the bot mentions it in a comment. This also acts as a notification about the automated backport being successfully made.
-
Verify titles of PRs targetting the maintenance branch
The bot adds a check run to the PR to indicate whether the PR contains a
[3.x]
prefix, and also leaves a small note in there if the title does not contain the original PR number. -
Check for Blocked labels
The bot reports the Blocked status for all PRs based on the PR's labels to avoid accidental merges of PRs that should not yet be merged.
-
[DISABLED] Auto-apply Resolution: Fix Committed and Resolution: Fix Released labels
The bot auto-applies Resolution: Fix Committed label on the issues that were closed by a PR.
On successful run of Publish Release workflow on the repository, the bot fetches associated PRs for all commits that were made between previous tag and the newly tagged release, and auto-applies Resolution: Fix Released label on the linked issues that were closed by that PR and had Resolution: Fix Committed label.
-
Auto-apply Changelog Entry: Pending label on PRs merged to
V3/develop
The bot auto-applies Changelong Entry: Pending label on the PRs that were merged to
V3/develop
branch if there is no other Changelon Entry label on it already.
Doesn't seem like much? Don't worry, we're still working on more!
-
- Set GitHub App name and Homepage URL (this can be repository URL).
- Deselect "Active" checkbox under the Webhook section - we will set it up later.
- Select needed "Repository permissions"
- "Checks", "Contents", "Issues", "Pull Requests" are used by this application
- Create the GitHub App
-
Deploy the application to fly.io.
-
Create the application on fly.io
$ flyctl launch An existing fly.toml file was found for app red-githubbot ? Would you like to copy its configuration to the new app (y/N) Yes Creating app in /../../Red-GitHubBot Scanning source code Detected a Dockerfile app ? Choose an app name (leave blank to generate one): red-githubbot ? Select Organization: cog-creators (cog-creators) ? Choose a region for deployment: San Jose, California (US) (sjc) Created app 'red-githubbot' in organization 'cog-creators' Admin URL: https://fly.io/apps/red-githubbot Hostname: red-githubbot.fly.dev ? Would you like to set up a Postgresql database now? Yes ? Select configuration: Development - Single node, 1x shared CPU, 256MB RAM, 1GB disk Creating postgres cluster in organization cog-creators Creating app... Setting secrets on app red-githubbot-db... Provisioning 1 of 1 machines with image flyio/postgres-flex:15.2@sha256:8e00d751bb9811bc8511d7129db2cc5a515449cf4a7def8f1d60faacb2be91c6 Waiting for machine to start... Machine ... is created ==> Monitoring health checks Waiting for ... to become healthy (started, 3/3) Postgres cluster red-githubbot-db created Username: postgres Password: ... Hostname: red-githubbot-db.internal Flycast: ... Proxy port: 5432 Postgres port: 5433 Connection string: postgres://postgres:...@red-githubbot-db.flycast:5432 Save your credentials in a secure place -- you won't be able to see them again! Connect to postgres Any app within the cog-creators organization can connect to this Postgres using the above connection string Now that you've set up Postgres, here's what you need to understand: https://fly.io/docs/postgres/getting-started/what-you-should-know/ Checking for existing attachments Registering attachment Creating database Creating user Postgres cluster red-githubbot-db is now attached to red-githubbot The following secret was added to red-githubbot: DATABASE_URL=postgres://red_githubbot:...@red-githubbot-db.flycast:5432/red_githubbot?sslmode=disable Postgres cluster red-githubbot-db is now attached to red-githubbot ? Would you like to set up an Upstash Redis database now? No ? Would you like to deploy now? No Your app is ready! Deploy with `flyctl deploy`
-
Set GitHub App ID under
GH_APP_ID
variableflyctl secrets set GH_APP_ID=...
-
Generate a webhook secret and set it under
GH_WEBHOOK_SECRET
variablepython -c "print(__import__('secrets').token_hex(32))" flyctl secrets set GH_WEBHOOK_SECRET=<SECRET HERE>
-
Generate a private key in GitHub App's settings and copy the contents of downloaded key to
GH_PRIVATE_KEY
variableflyctl secrets set GH_PRIVATE_KEY=- < key.pem
-
Generate a personal access token for the bot's machine account and set it under
GH_AUTH
variableflyctl secrets set GH_AUTH=...
-
Deploy the application
-
-
Add a webhook to the GitHub App.
- Use
https://{app_name}.herokuapp.com/webhook
as Webhook URL - Use the previously generated webhook secret (used in
GH_WEBHOOK_SECRET
variable) as Webhook secret - Save changes
- Use
-
Install the App on selected repositories.
-
- Set GitHub App name and Homepage URL (this can be repository URL).
- Deselect "Active" checkbox under the Webhook section - we will set it up later.
- Select needed "Repository permissions"
- "Checks", "Contents", "Issues", "Pull Requests" are used by this application
- Create the GitHub App
-
Deploy the application to Heroku.
-
Set GitHub App ID under
GH_APP_ID
variable -
Generate a webhook secret and set it under
GH_WEBHOOK_SECRET
variablepython -c "print(__import__('secrets').token_hex(32))"
-
Generate a private key in GitHub App's settings and copy the contents of downloaded key to
GH_PRIVATE_KEY
variable -
Generate a personal access token for the bot's machine account and set it under
GH_AUTH
variable -
Deploy the application
-
-
Add a webhook to the GitHub App.
- Use
https://{app_name}.herokuapp.com/webhook
as Webhook URL - Use the previously generated webhook secret (used in
GH_WEBHOOK_SECRET
variable) as Webhook secret - Save changes
- Use
-
Install the App on selected repositories.
To enable Sentry integration, you need to:
-
(if on Heroku) Enable Dyno Metadata feature from Heroku Labs
-
Set Sentry client key under
SENTRY_DSN
variable for error tracking.You can find this on the 'Client Keys (DSN)' page in the Sentry project's settings.
-
Re-deploy the application
See the LICENSE file for details.
Huge thanks to Mariatta and her miss-islington bot, as well as Brett Cannon and his bedevere bot which were both a huge help when implementing backport-related functionality.