Skip to content

Instantly share code, notes, and snippets.

@vicalloy
Created June 20, 2018 05:18
Show Gist options
  • Save vicalloy/4e0ac9a63aff7633f95030e22da9fec3 to your computer and use it in GitHub Desktop.
Save vicalloy/4e0ac9a63aff7633f95030e22da9fec3 to your computer and use it in GitHub Desktop.
Github event handler
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