Skip to content

A Slack Integration to speed up Pull Request reviews for organizations on Slack 🐨

Notifications You must be signed in to change notification settings

abinavseelan/review-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review-Bot

A Slack Integration to speed up Pull Requests Reviews for Organizations using Slack and Github 🐨

Features: (as of Version 1.0)

  • 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.

Setup - TL;DR version

  • Clone the repository git clone git@github.com:abinavseelan/review-bot.git
  • Create a config.js file in the root of your project. Set the slack_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!

Setup - Full Guide:

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! 😄)

Step 1: Clone the repository

clonefromgithub

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

Step 2: Create a Heroku Application

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

heroku remote

Step 3: Create a Slack Incoming Integration

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

incomingwebhooklanding

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!

incomingwebhookcustomization

Step 4: Create a Configuration File

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.

Step 5: Deploy to Heroku 🚀

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

botpong

Step 6: Configuring Github

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.

settings

Click on the Webhooks option on the side menu

webhooklandin

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.

webhook1

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.

webhook2

And that's that! Click Save and you have a working Slack integration/bot that will monitor the configured repository for Pull Request Activity.