Giter VIP home page Giter VIP logo

githubconnector's Introduction

โš ๏ธ This repository is no longer maintained


GitHub Connector

This small app aims at posting a notification in a channel whenever a reviewer is requested for a PR in GitHub.

Notification

Originally, it was aiming at mentioning the requested reviewer, so that he/she gets a personal notif. But... the API from Teams does not allow it for now ๐Ÿ˜ญ

Note that a very similar connector already exists (GitHub Enterprise), but it ignores notifications of type review_requested.

Info

  • This is a Node.js app, thus requires npm
  • Limitations:
    • Supports only the review_requested events from GitHub, others events are ignored
    • Unfortunately, MS Teams does not provide an API to mention some one, which is a bit frustrating since the reviewer cannot be personally notified. In order to receive notifications, everybody has to follow the channel, and will ve notified of all review requests, which is a bit of pollution.

Setup

There are 3 steps that must be done. Each step is described later in the doc.

  1. Create an incoming WebHook in MS Teams
  2. Run the app (locally or in MS Teams)
  3. Create an outgoing WebHook in GitHub

Create an incoming WebHook in MS Teams

  • Setup an incoming WebHook in your MS Teams channel (doc), and note its URL (something like https://outlook.office.com/webhook/...).
  • Put the WebHook URL in the config file config/default.json.

Run the app

The app is a simple Node.js server, and basically it must be reachable from your GitHub server.

Two options here:

  • either run locally (recommenced to make a quick test),
  • or host your app on Azure.

Note: you may also setup a static internal server for your enterprise, as long as it can be reached from your GitHub enterprise.

Locally

  • Make sure to have npm installed
  • Clone this repo
  • Move to the repo root folder and run npm start, the app will start on http://localhost:3000
  • Then, in order to be reachable from Internet, you may use ngrok to create a temporary tunnel
    • Download and install it
    • Then run it to bind your locally running app ./ngrok http 3000 -host-header=localhost:3000
    • Now your local running app is reachable from Internet with something like https://<RANDOM_ID>.ngrok.io
    • This URL is what you have to use in GitHub, see below.

Host on Azure

Create an outgoing WebHook in GitHub

  • Copy the URL of your running app
  • In your GitHub repository:
    • Add a WebHook in the settings, with the URL of your running app.
    • Make sure to configure it with JSON as content-type (application/json).
    • No need for a secret / authorization
    • Fine-tune the events that you want to be sent. Currently, only the PR review requests are supported by the connector, the other ones are ignored, so you can select option Let me select individual events, and then only tick checkbox Pull requests
    • Make sure that the WebHook is marked as Active

Test it

  • Of course the code has some automatic tests implemented: npm test
  • You can simulate GitHub notification by simply send a POST (with Postman for example) on the app URL, with a an appropriate JSON payload, e.g.:
{
    "action": "review_requested",
    "pull_request": {
        "title": "Added a crazy new feature",
        "_links": {
            "html": {
                "href": "https://any.domain.com/myrepo/pull/1"
            }
        },
        "additions": 14,
        "deletions": 3,
        "changed_files": 2
    },
    "requested_reviewer": {
        "login": "bill-gates"
    },
    "repository": {
        "name": "MyRepo"
    },
    "sender": {
        "login": "steve-jobs",
        "avatar_url": "https://www.apple.com"
    }
}
  • From your GitHub repository:
    • Create a PR, then go to the Settings, find your WebHook and see the events it has sent. The response must be a 200 OK but with text saying that this notif was ignored.
    • Add some one as a reviewer for your PR in GitHub, and check the WebHook event, response must be a 200 OK without text.
    • In your channel in Teams, you should see a message.
    • Note that a message from GitHub can be redelivered, which can be nice for testing.

githubconnector's People

Contributors

teemoo7 avatar

Watchers

 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.