A Slackbot for GitHub monorepos. Configure how repo notifications should be routed to specified Slack channels based on file prefixes, issue/PR labels, and CI build statuses.
Check out the accompanying blog post for an overview of Monorobot.
Install via OPAM:
opam install monorobot
Or install dependencies and build locally:
opam install --deps-only .
make
Run the _build/default/src/monorobot.exe binary. The following commands are supported.
run: Launch the HTTP servercheck_gh <GH_PAYLOAD>: read a Github notification from a file and display the actions that will be taken (used for testing)check_slack <SLACK_PAYLOAD>: read a Slack notification from a file and send it to a channel (used for testing)For local development, use the dev server which rebuilds and restarts on file changes:
make dev
Pass arguments to the monorobot binary via ARGS. E.g.:
make dev ARGS="run -p 3000 --state=state.json"
repo scope and store it in the gh_token field of the secrets file.
To use the "Project Owners" feature, the token owner must have triage role or above for the repository.<server_domain>/github.head -c 30 /dev/urandom | base64), and store it in the gh_hook_secret field of the secrets file.chat:write (for per-channel authorization) or chat:write.public (for authorization to all channels). Also give chat:write.customize (to show branch name as bot username). If you want to send direct messages, also add the users:read.email scope, whichis necessary to find the user id matching the email of a commit author. Copy the generated bot token (xoxb-XXXX) to the slack_access_token field of your secrets file. This token is used by the bot to authenticate to the workspace, and remains valid until the token is revoked or the app is uninstalled. If you use the chat:write scope, add the bot to each channel you want to notify.include_logs_in_notifs set to true (which is the default), then you need the scope files:write and channels:join.slack_hooks field of your secrets file. If you decide to notify additional channels later, you will need to update the secrets file with the new webhooks and restart the server.You can configure Monorobot to unfurl GitHub links in Slack messages. Currently, commit, pull request, and issue links are supported.
Note: The slack_access_token must be configured in your secrets file for link unfurling. See previous section for details.
links:read and links:write permissions.<server_domain>/slack/events. Ensure the server is running before triggering the handshake.Monorobot will also try to match mentioned GitHub handles (e.g., in PR/issue/commit comments) to Slack emails. Where there is a match between canonicalised GitHub handle and canonicalised Slack email, the GitHub mention in Monorobot's notification will be replaced with a Slack mention. This feature requires slack_access_token to be configured, and your app must also have the users:read permission. See the previous section for how to set this up.
If your canonicalised GitHub handle is different from your canonicalised Slack email, or if you want to override this default matching scheme, you can create a manual mapping in your repository configuration under the user_mappings option. See the documentation for details.
When a pipelinel is configured with a failed builds channel, Monorobot will send notifications to that Slack channel when a build fails for the main branch in the configured pipeline. This notification will mention the commit author and the build steps broken by the commit. This is useful for tracking the status of builds in Slack, and for getting notifications when a build fails.
Currently, this feature is only supported for Buildkite builds.
The logic is as follows:
Some examples:
a and b, build #2 then breaks steps a and c.
a and b, and for build #2 regarding the step c.a and b, build #2 breaks step a and c, build #3 breaks step a and b.
b and build #3 broke it again. So we notify the channel like above for the first two builds, and for build #3 regarding the step b only.a in the process and we get the notification (with which we update the builds state), build #2 breaks step a and b. Build #2 finishes before build #1.
b. Then build #1 finishes and we notify the channel for the steps that build #1 newly broke.a and b, and then again for build #1.Commit a configuration file to the root of each repository you want to support, and add a secrets file on the bot server itself. Read on for instructions to set up each file:
curl -X POST \
http://localhost:8080/github \
-H 'Content-Type: application/json' \
-H 'User-Agent: {whatever user agent you define}' \
-H 'X-Github-Event: pull_request' \
-H 'X-Hub-Signature: {a signature value you define}' \
-H 'cache-control: no-cache' \
-d @mock_payloads/pr_notification.json
There are more payloads which will use a different X-Github-Event signature:
pull_request => mock_payloads/pr_notification.json
push => mock_payloads/push_notification.json
check_suite => mock_payloads/ci_notification.json
OCaml
90.8%
Turing
8.4%
A Slackbot for GitHub monorepos. Configure how repo notifications should be routed to specified Slack channels based on file prefixes, issue/PR labels, and CI build statuses.
Check out the accompanying blog post for an overview of Monorobot.
Install via OPAM:
opam install monorobot
Or install dependencies and build locally:
opam install --deps-only .
make
Run the _build/default/src/monorobot.exe binary. The following commands are supported.
run: Launch the HTTP servercheck_gh <GH_PAYLOAD>: read a Github notification from a file and display the actions that will be taken (used for testing)check_slack <SLACK_PAYLOAD>: read a Slack notification from a file and send it to a channel (used for testing)For local development, use the dev server which rebuilds and restarts on file changes:
make dev
Pass arguments to the monorobot binary via ARGS. E.g.:
make dev ARGS="run -p 3000 --state=state.json"
repo scope and store it in the gh_token field of the secrets file.
To use the "Project Owners" feature, the token owner must have triage role or above for the repository.<server_domain>/github.head -c 30 /dev/urandom | base64), and store it in the gh_hook_secret field of the secrets file.chat:write (for per-channel authorization) or chat:write.public (for authorization to all channels). Also give chat:write.customize (to show branch name as bot username). If you want to send direct messages, also add the users:read.email scope, whichis necessary to find the user id matching the email of a commit author. Copy the generated bot token (xoxb-XXXX) to the slack_access_token field of your secrets file. This token is used by the bot to authenticate to the workspace, and remains valid until the token is revoked or the app is uninstalled. If you use the chat:write scope, add the bot to each channel you want to notify.include_logs_in_notifs set to true (which is the default), then you need the scope files:write and channels:join.slack_hooks field of your secrets file. If you decide to notify additional channels later, you will need to update the secrets file with the new webhooks and restart the server.You can configure Monorobot to unfurl GitHub links in Slack messages. Currently, commit, pull request, and issue links are supported.
Note: The slack_access_token must be configured in your secrets file for link unfurling. See previous section for details.
links:read and links:write permissions.<server_domain>/slack/events. Ensure the server is running before triggering the handshake.Monorobot will also try to match mentioned GitHub handles (e.g., in PR/issue/commit comments) to Slack emails. Where there is a match between canonicalised GitHub handle and canonicalised Slack email, the GitHub mention in Monorobot's notification will be replaced with a Slack mention. This feature requires slack_access_token to be configured, and your app must also have the users:read permission. See the previous section for how to set this up.
If your canonicalised GitHub handle is different from your canonicalised Slack email, or if you want to override this default matching scheme, you can create a manual mapping in your repository configuration under the user_mappings option. See the documentation for details.
When a pipelinel is configured with a failed builds channel, Monorobot will send notifications to that Slack channel when a build fails for the main branch in the configured pipeline. This notification will mention the commit author and the build steps broken by the commit. This is useful for tracking the status of builds in Slack, and for getting notifications when a build fails.
Currently, this feature is only supported for Buildkite builds.
The logic is as follows:
Some examples:
a and b, build #2 then breaks steps a and c.
a and b, and for build #2 regarding the step c.a and b, build #2 breaks step a and c, build #3 breaks step a and b.
b and build #3 broke it again. So we notify the channel like above for the first two builds, and for build #3 regarding the step b only.a in the process and we get the notification (with which we update the builds state), build #2 breaks step a and b. Build #2 finishes before build #1.
b. Then build #1 finishes and we notify the channel for the steps that build #1 newly broke.a and b, and then again for build #1.Commit a configuration file to the root of each repository you want to support, and add a secrets file on the bot server itself. Read on for instructions to set up each file:
curl -X POST \
http://localhost:8080/github \
-H 'Content-Type: application/json' \
-H 'User-Agent: {whatever user agent you define}' \
-H 'X-Github-Event: pull_request' \
-H 'X-Hub-Signature: {a signature value you define}' \
-H 'cache-control: no-cache' \
-d @mock_payloads/pr_notification.json
There are more payloads which will use a different X-Github-Event signature:
pull_request => mock_payloads/pr_notification.json
push => mock_payloads/push_notification.json
check_suite => mock_payloads/ci_notification.json
OCaml
90.8%
Turing
8.4%