Giter VIP home page Giter VIP logo

github-review-slack-notifier's Introduction

github-slack-notifier

This is a very basic flask server using Flask-Hookserver to respond to custom github webhooks.

Coverage Status Build Status

What it does

When a pull request hook is received, the app does the following things:

  1. Check the action on the PR webook. Only continues if it is a review request or assignment
  2. Look up all slack users
  3. Attempt to match the github username to a slack username or displayname
  4. If there is no match, it will retrieve the github user's full name via the API and attempt to match it to a slack full name.
  5. If there is no matched username, it will use a generic phrase, and post the message in the default channel
  6. If a matched slack username is found, a message will be sent to the matched user only.
  7. The message will contain:
  • Github Repo & PR #
  • A link to the PR
  • PR Title and description
  • The author of the PR
  • A random octocat (because why not?)

Setup

First, create a custom slack bot. Get the API Key.

Next, get a Github API Key. This is needed to lookup a user's full name.

Next, create a custom github webhook on your repo or organization. The pull request event is currently the only event that matters. Make note of the secret Point the URL to where you will be hosting your code. Make sure to include /hooks. e.g. https://my-github.example.com/hooks

Finally, host the code on a server that github can reach. You will need the following environment variables:

export SLACK_BOT_TOKEN='<YOUR SLACKBOT TOKEN>'
export GITHUB_WEBHOOKS_KEY='<YOUR WEBHOOK SECRET'
export GITHUB_API_TOKEN='<YOUR GITHUB API TOKEN>'
export GITHUB_API_USER='<YOUR GITHUB API USERNAME>'
export DEFAULT_NOTIFICATION_CHANNEL='#<YOUR DEFAULT SLACK CHANNEL>'

TODO

  • notification of review completion
  • The slack user lookup is not cached.
  • Perhaps would be better as an app that stores the github/slack username link.
  • The matching is imprecise and would probably break with two people of the same name.

github-review-slack-notifier's People

Contributors

gidgidonihah avatar shaggyd avatar

Watchers

Piyush Nimbalkar avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.