It checks your repo for open pull requests, then sends a message to your designated Slack channel with the details.
It can be used as a kind of stand-up - a reminder of PRs that need reviewing, a way to see if there are stale PRs we can purge, merge or refactor.
You'll need an app and a bot user configured to do the posting for you. Visit Slack's documentation to learn how to create an App and how to create the bot user.
Visit the "OAuth & Permissions" section on your App's settings page to configure these - it will need the following permissions at a minimum:
channels:join
chat:write
incoming-webhook
Once configured, add the App to your workspace - this will generate an Oauth token (same page as above) - you'll need this later. You then need to invite it the bot to the channel that you plan to send messages to.
Mine is called Patrick:
Add the following to a file called something like pr-monitor.yml
to your .github/workflows
directory:
on:
schedule:
# 9:25 am Mon-Fri, just in time for stand up
- cron: '25 9 * * 1-5'
jobs:
pr-monitor-job:
runs-on: ubuntu-latest
name: PR monitor
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Scan for PRs
id: scan
uses: andrewandante/[email protected]
with:
# required inputs
slack-token: ${{ secrets.SLACK_OAUTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
# optional inputs (with defaults set)
channel: '#pr-monitor'
sort: 'updated'
sort-direction: 'desc'
approved-emoji: 'heavy_check_mark'
pending-emoji: 'heavy_minus_sign'
changes-requested-emoji: 'x'
requested-reviewer-emoji: 'heavy_minus_sign'
Oauth token of the App, used to authenticate the bot user so the message can be
posted. Here, you should save the Oauth token (should start with xoxb-
) as a
secret on the repo - I've called it SLACK_OAUTH_TOKEN
in the example.
Used to authenticate the Github API, as we are looping through reviewers and pull
requests and such. secrets.GITHUB_TOKEN
is defined by default, so you should
just use that.
The channel to post to in Slack. Make sure the bot user is invited!
What field the pull requests are sorted on when retrieved. See (the Octokit docs)[https://octokit.github.io/rest.js/#octokit-routes-pulls-list] for further explanation. Valid values are 'created', 'updated', 'popularity' or 'long-running'
The order of the sort. Can also be 'asc'.
The emoji to use for a pull request review that has approved the changes (minus the wrapping colons)
The emoji to use for a pull request review that is pending (minus the wrapping colons)
The emoji to use for a pull request review that has requested changes (minus the wrapping colons)
The emoji to use for a pull request review has been requested but not begun (minus the wrapping colons)
Shout out to stojg/purr, the first iteration of this idea that motivated me enough to learn Javascript just to write it.