Skip to content

Instantly share code, notes, and snippets.

@samjaninf
Forked from vicalloy/webhook.py
Created October 23, 2019 21:09
Show Gist options
  • Save samjaninf/f8a0e64badd65857cec732a1ab59443d to your computer and use it in GitHub Desktop.
Save samjaninf/f8a0e64badd65857cec732a1ab59443d 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