This will notify pull-request events to your Slack channel.
Notify the pull request reviewer that a review request is coming, Notify the pull request author as soon as the reviewer completes the approval.
- Post a message to Slack when a particular user is added as a reviewer to a pull request
- Update messages already posted at the following events
- Yet another specific user is added as a reviewer
- Reviewer completes review
- Pull requests are merged
- The update history is threaded to the message
- Mention the Slack account of the target GitHub user
This system is designed to be hosted on Deno Deploy.
Posting to Slack uses the Slack Block API to create a dialog-like appearance.
Use Slack's metadata API to find messages to update. In this way, the channel is not wasted. Fortunately, pull requests have a unique number, so I can simply use that as my search key.
GraphQL(GitHub v4) was used as the method for acquiring detailed data of pull request. It was very convenient because it took less effort than the REST API(GitHub v3).
Store the bot token needed to use the Slack API in Deno Deploy Secrets. The Slack channel ID, Slack and Github account pair, will be stored in Deno KV.
Holds a token for operating GitHub in Deno Deploy Secrets too.
- serve.ts: The API server.
- createContext.ts: Adjust the JSON of the received webhook.
- postNotification.ts:
- getActualGraph.ts: GraphQL
- renderer.tsx: jsx-slack
- Event > Activity Type
- pull_request
- opened
- Even if a review request is made at the same time as the PR opens, the events will occur separately.
- closed
- When a pull request merges, the
pull_request
is automaticallyclosed
. - with a conditional that checks the
merged
value of the event. alsomerged_by
.
- When a pull request merges, the
- edited
- reopened
- I don't know...
- review_requested
- see
payload.requested_reviewer
.
- see
- review_request_removed
- see
payload.requested_reviewer
.
- see
- opened
- pull_request_review
- submitted
- when a pull request has been approved
- check the
payload.review.state
, state ==approved
then PR was approved.
- dismissed
- Change the state of the review, but not the state of the PR.
- submitted
- pull_request_review_comment
- created
- pull_request
- views.open, views.update
- scope: No scope required
- chat.postMessage, chat.update
- scope:
chat:write
- scope:
- conversations.history
- scope:
channels:history
,groups:history
,im:history
,mpim:history
- scope:
- Slash command
- scope:
commands
- scope:
- GITHUB_TOKEN: GitHub personal access token (classic)
- for example,
ghp_abcdefghijklmnopqrstuvwxyz0123456789
- for example,
- SLACK_TOKEN: Slack Bot token with scopes as above.
- for example,
xoxb-1234567890123-1234567890123-abcdefghijklmnopqrstuvwx
- for example,