Created
June 20, 2018 05:18
-
-
Save vicalloy/4e0ac9a63aff7633f95030e22da9fec3 to your computer and use it in GitHub Desktop.
Github event handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import abort | |
from bottle import post | |
from bottle import request | |
from bottle import run | |
from subprocess import call | |
def handle_pull_request(o): | |
pass | |
def handle_push(o): | |
call(["git", "pull"]) | |
def handle_ping(o): | |
handle_push(o) | |
@post('/github/payload') | |
def event_dispatcher(): | |
event = request.headers.get('X-GitHub-Event') | |
try: | |
handler = globals()['handle_%s' % event] | |
except KeyError: | |
abort(403, 'Unable to handle GitHub event "%s"' % event) | |
else: | |
return handler(request.json) | |
run(host='0.0.0.0', port=9020, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment