Coder Social home page Coder Social logo

github-webhook-handler's Introduction

Flask webhook for Github

A very simple github post-receive web hook handler that executes per default a pull uppon receiving. The executed action is configurable per repository.

It will also verify that the POST request originated from github.com or a defined GitHub Enterprise server. Additionally will ensure that it has a valid signature (only when the key setting is properly configured).

Gettings started

Installation Requirements

Install dependencies found in requirements.txt.

pip install -r requirements.txt

Repository Configuration

Edit repos.json to configure repositories, each repository must be registered under the form GITHUB_USER/REPOSITORY_NAME.

{
    "razius/puppet": {
        "path": "/home/puppet",
        "key": "MyVerySecretKey",
        "action": [["git", "pull", "origin", "master"]]
    },
    "d3non/somerandomexample/branch:live": {
    "path": "/home/exampleapp",
        "key": "MyVerySecretKey",
    "action": [["git", "pull", "origin", "live"],
    ["echo", "execute", "some", "commands", "..."]]
}
}

Runtime Configuration

Runtime operation is influenced by a set of environment variables which require being set to influence operation. Only REPOS_JSON_PATH is required to be set, as this is required to know how to act on actions from repositories. The remaining variables are optional. USE_PROXYFIX needs to be set to true if being used behind a WSGI proxy, and is not required otherwise. GHE_ADDRESS needs to be set to the IP address of a GitHub Enterprise instance if that is the source of webhooks.

Set environment variable for the repos.json config.

export REPOS_JSON_PATH=/path/to/repos.json

Start the server.

python index.py 80

Start the server with root privileges, if required, while preserving existing environment variables.

sudo -E python index.py 80

Start the server behind a proxy (see: http://flask.pocoo.org/docs/deploying/wsgi-standalone/#proxy-setups)

USE_PROXYFIX=true python index.py 8080

Start the server to be used with a GitHub Enterprise instance.

GHE_ADDRESS=192.0.2.50 python index.py 80

Go to your repository's settings on github.com or your GitHub Enterprise instance and register your public URL under Webhooks & services -> Webhooks.

github-webhook-handler's People

Contributors

razius avatar kcirtapw avatar darrelclute avatar brandon15811 avatar blha303 avatar gdoteof avatar sprin avatar jag3773 avatar lheckemann avatar magnunleno avatar nickvasilyev avatar

Watchers

 avatar 长毛是狗 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.