Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Configuring the Bot

Simon Baslé edited this page Apr 15, 2021 · 1 revision

The bot is intended to be mainly configured via environment variables. That said, it uses Spring Boot property sources, so it can resolve property from any relevant source.

Example of a configuration defined via applications.properties

See the example / default in src/main/resources/application.properties

slack.incomingWebHook=https://slack.my.org/channelWebHook/
# /!\ avoid storing this type of secrets in deployed application.properties, see below
slack.botToken={SECRET_TOKEN}
slack.botId=U12ABC5678

server.port=9090

github.botUsername=reactorbot
# /!\ avoid storing this type of secrets in deployed application.properties, see below
github.token={SECRET_TOKEN}
github.noCancel=false

github.repos.main.repo=reactor-core
github.repos.main.org=reactor
github.repos.main.watchedLabel=PR-fast-track
github.repos.main.triageLabel=:question:need-triage
github.repos.main.maintainers.githubusername1=U12ABC1111
github.repos.main.maintainers.githubusername2=U12ABC2222

Example of a configuration defined via environment variables

`SLACK_INCOMINGWEBHOOK` = `https://slack.my.org/channelWebHook/`
`SLACK_BOTTOKEN` = `{SECRET_TOKEN}`
`SLACK_BOTID` = `U12ABC5678`

`GITHUB_BOTUSERNAME` = `reactorbot`
`GITHUB_TOKEN` = `{SECRET_TOKEN}`
`GITHUB_NOCANCEL` = `false`

`GITHUB_REPOS_MAIN_REPO` = `reactor-core`
`GITHUB_REPOS_MAIN_ORG` = `reactor`
`GITHUB_REPOS_MAIN_WATCHEDLABEL` = `PR-fast-track`
`GITHUB_REPOS_MAIN_TRIAGELABEL` = `:question:need-triage`
`GITHUB_REPOS_MAIN_MAINTAINERS_GITHUBUSERNAME1` = `U12ABC1111`
`GITHUB_REPOS_MAIN_MAINTAINERS_GITHUBUSERNAME2` = `U12ABC2222`

GitHub-related properties

All these properties are to be prefixed with github. (in properties files) or GITHUB_ (in environment variables).

There are root level properties for GitHub, as well as a mean to tune things on a repository basis.

  • botUsername: the handle of the bot on GitHub (not including the @)

  • token: the secret token to authenticate the bot on GitHub

  • noCancel: true if removing the fast-track label from a pull request shouldn’t remove the bot’s approval (see watchedLabel in per-repo config)

  • mergeHintRepos: a comma-separated list of repository names to watch for PR merges on maintenance branches. The bot will remind to perform a forward-merge in such PRs.

  • repos: root for configuring repository mappings (see below)

Repository mapping can be configured with the Map syntax, using github.repos.x. as a prefix for a configuration named x. With environment variables, this is instead in the GITHUB_REPOS_X_ format. Each repo can define the following properties:

  • org: the organization in which the repository resides

  • repo: the name of the repository

  • watchedLabel: the String matching the GitHub label to watch for triggering the fast-track approval

  • triageLabel: the String label to apply on newly created issues created without a label

  • maintainers: a Map of maitainers/codeowners. Only maintainers can request a fast-track, and other maintainers are then notified on Slack — this is a simple key-value pair of the GitHub handle (as the suffix) and the corresponding Slack UserID (as the value) — For example, for the repo EXAMPLE, GitHub user BOB has id U1X1X1X on Slack: --- as an environment variable: GITHUB_REPOS_EXAMPLE_MAINTAINERS_BOB would be set to U1X1X1X --- in a property file, we would have the entry: github.repos.example.maintainers.bob=U1X1X1X

Tip
A blanket configuration can be specified for a given organization by using the * character as the repository’s name.

Slack-related properties

All these properties are to be prefixed with slack. (in properties files) or SLACK_ (in environment variables).

  • incomingWebhook: the URL at which to push Slack messages, usually mapping to the Slack Channel in which you want the bot to post

  • botToken: the Slack user token for the bot’s account

  • botId: the Slack User ID for the bot’s account (this is not the @handle of the bot)

  • individual repo maintainers configuration maps the github username to the relevant Slack user ID, see above.

Finding one’s Slack UserID

  1. Open the Slack profile of the user for whom you want to find the UserID ("View Profile", ie. the fuller profile view)

  2. Notice the user handle is displayed in the profile, but we want the ID

  3. Click on "…​ More"

  4. Click on "Copy member ID"

Configuring locally

The bot defines a custom EnvironmentPostProcessor, which means that one can override properties by adding entries to:

{USER_HOME]/.reactor-bot/reactor-bot.properties

This allows to test the bot locally with secrets stored in this file rather than in the source (removing the risk to accidentally commit such secrets).