A Slack Integration to speed up Pull Requests Reviews for Organizations using Slack and Github 🐨
- Supports Slack Notifications (messages) for the following events:
- Requesting a Reviewer for a Pull Request.
- Approving a Pull Request.
- Submitting a review with general comments.
- Submitting a review requesting changes.
- Direct link to pull request in the Slack message.
- Clone the repository
git clone git@github.com:abinavseelan/review-bot.git
- Create a
config.js
file in the root of your project. Set theslack_webhook
variable and export it.
module.exports = {
slack_webhook: "<your slack integration\'s webhook>"
};
- Deploy 🚀!
- On your github repository's settings, add a new webhook and set the payload url to your server's
/github
endpoint. (eg.<domain/ip of server>/github
) - Add the integration to your slack channel!
The full guide will help you setup the bot to work with your Slack Channel and your Github Repository. The bot will be deployed to Heroku, a free and rather awesome Cloud hosting provider for NodeJS applications.
The only assumptions we will be making are that you know how to use the terminal and have some basic knowledge of Git and pushing to remote repositories. (If you've already used Github, then you know what a remote repository is! 😄)
Copy the link from the Clone
Tab and in your terminal, clone the repository using the $ git clone
command
$ git clone https://github.com/abinavseelan/review-bot.git
Prerequisite: The Heroku CLI is required to connect to Heroku via the Command Line. Visit this setup guide to download the required dependencies.
Once you're all set with :point-up:, make sure you're inside the repository folder and run heroku create
. This will create a Heroku application (technically a repository on Heroku) and the repository will be added as a remote repository to your local repository called heroku
To create Slack Integration for your Slack Organization, head over to https://<your_organization_name>.slack.com/apps/build/custom-integration
and click on Incoming WebHooks
This will take you to the Customization Page. There are a few things you can do here. You can set which channel you want the integration to be a part of, you can set the icon for the integration. The most important entity however is the Slack Webhook Url. Copy this URL!
In the root of the project, create a config.js
file. In that file, add the following code.
module.exports = {
slack_webhook: "<paste_the_copied_slack_webhook_url_here>"
};
This tells our bot which URL to hit when information from pull requests comes to it.
You're all set! Now we just need to do one more thing to make this (or rather your) application live.
Inside the repository folder, commit the new config.js
file using the git commit
command. Once you've commited the file, you can push all the code to Heroku using git push heroku master
. This will push all your local files to Heroku's remote repository. Heroku will now take those files and start the Bot for us.
When you run the git push heroku master
command, you'll see the build logs from Heroku. Once it's done, it will display the public url that your application/bot is running on.
To test if your application is running or not, just visit <heroku_public_url_for_your_app>/ping
on your browser and you should see the following output
Now that we have the Bot up and running, we need to configure the github repositories for which we want the Bot to monitor Pull request activity.
Got to the repository you want to monitor and click on the Settings
icon.
Click on the Webhooks
option on the side menu
Click on Add Webhook
on the right side corner. You might be prompted for your Github Password. Once that's done, you should be taken to a screen that looks like this.
There, in the payload url
section, add <heroku_public_url_for_your_app>/github
.
Scroll down a little and you will see that you can choose what events you want Github to notify the Bot on. Choose the following options, just to reduce the load on the Bot.
And that's that! Click Save
and you have a working Slack integration/bot that will monitor the configured repository for Pull Request Activity.