softdevteam/mattermost-github-integration

Name: mattermost-github-integration

Owner: Software Development Team

Description: GitHub integration for Mattermost

Created: 2016-01-19 14:24:18.0

Updated: 2018-03-23 08:43:24.0

Pushed: 2018-03-06 11:32:13.0

Homepage:

Size: 93

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Github integration for Mattermost

Inspired by mattermost-integration-gitlab this program creates a server using flask that listens for incoming GitHub event webhooks. These are then processed, formatted, and eventually forwarded to Mattermost where they are displayed inside a specified channel.

Requirements
System requirements
Application requirements

All requirements can also be installed using the command

pip install -r requirements.txt

Installation and usage
Method 1: running the application from the project directory
  1. Clone the repository
  2. Within the mattermostgithub directory, copy config.template to config.py and edit it with your details. For example:
NAME = "Github"
_URL = "yourdomain.org/github.png"
ERMOST_WEBHOOK_URLS = {
'default' : ("yourdomain.org/hooks/hookid", "off-topic"),
'teamname/repositoryname' : ("yourdomain.org/hooks/hookid2", "repository-channel-id"),
'teamname' : ("yourdomain.org/hooks/hookid3", "town-square"),
'teamname/unimportantrepo' : None,

UB_IGNORE_ACTIONS = {
"issues": ["labeled", "assigned"],

ET = 'secretkey'
_AVATARS = True
ER = {
'hook': "/"
'address': "0.0.0.0"
'port': 5000

Start the server with python server.py.

Method 2: installing the application with pip
  1. Create a virtualenv:
ualenv -p python3 env
v/bin/activate
  1. Install with pip
install git+https://github.com/softdevteam/mattermost-github-integration
  1. Download config.template and save it as config.py on your machine, changing your details as described above.

The project can then be run as a flask application:

rt FLASK_APP=mattermostgithub
rt MGI_CONFIG_FILE=path/to/config.py
k run
Webhooks

GitHub messages can be delegated to different Mattermost hooks. The order is as follows:

Repositories can be blacklisted by setting them to None instead of (url, channel).

Ignore actions

Specific Github events can be ignored by adding GITHUB_IGNORE_ACTIONS to config.py. In the example above labeled and assigned events for issues are ignored, while opened, closed, etc. events will continue to show up on Mattermost.

Server settings

The server is listening by default on address 0.0.0.0, port 5000, and using / as base route. Make sure to point your Github webhooks to http://yourdomain.org:5000/.

If you have a proxy/load-balancer in front of your machine, and do not want to expose port 5000 to the outside, change the SERVER['hook'] value and redirect it to this service. For example, if SERVER['hook'] is /hooks/github, your Github webhooks would be http://yourdomain.org/hooks/github.

Secret

If you don't want to use a secret set the field to None.

Deploying with Docker

To deploy with Docker, make sure you have Docker installed and run:

er build --rm=true -t mm-github .
er run --rm -v "$(pwd)":/home/app -w /home/app -p 5000:5000 -ti mm-github

If you want to run in background mode, change the option --rm for -d.

Supported Events

Not all Github events are forwarded to Mattermost. Currently supported events are:

All other events will report back to GitHub with 400 Not Implemented.

Known issues

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.