Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on slack mentions #150

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Note: The `slack_access_token` must be configured in your secrets file for link
1. Configure your app to [support the Events API](https://api.slack.com/events-api#prepare). During the [url verification handshake](https://api.slack.com/events-api#the-events-api__subscribing-to-event-types__events-api-request-urls__request-url-configuration--verification__url-verification-handshake), you should tell Slack to direct event notifications to `<server_domain>/slack/events`. Ensure the server is running before triggering the handshake.
1. [Register the GitHub domains](https://api.slack.com/reference/messaging/link-unfurling#configuring_domains) you want to support.

### Slack mentions

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](./documentation/config_docs.md) for details.

### Documentation

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:
Expand Down
7 changes: 7 additions & 0 deletions documentation/config_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Refer [here](https://docs.github.com/en/free-pro-team@latest/developers/webhooks
"ignored_users": [
"ignored_user"
],
"user_mappings": {
"[email protected]": "[email protected]",
"gh-handle": "[email protected]"
},
"prefix_rules": {
...
},
Expand All @@ -41,6 +45,9 @@ Refer [here](https://docs.github.com/en/free-pro-team@latest/developers/webhooks
| `status_rules` | status rules config object | all status notifications are ignored |
| `project_owners` | project owners config object | no project owners are defined |
| `ignored_users` | list of users to be ignored on all notifications | no user is ignored |
| `user_mappings` | list of mappings from git email and/or GitHub handle to Slack email | no mapping defined

Note that in `user_mappings`, git email to Slack email mappings are used for status DMs, while GitHub handle to Slack email mappings are used to get Slack mentions in notifications.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not explained why need to map by handle when email also available, the latter should be always better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Email is only available for commits and pushes, and it's the one from git config user.email if I understand correctly, and that's what I meant by "git email" in the readme. So it's possible to match between emails for CI status DMs. In other types of comments we only have access to the GitHub handle. I can make this clearer in documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @rr0gi meant to explain the design considerations and decisions on the "GitHub handle to Slack email mappings are used to get Slack mentions in notifications" part, i.e. why not use git email to Slack email too?


## Label Options

Expand Down