Created
June 3, 2013 08:26
-
-
Save NickWoodhams/5696838 to your computer and use it in GitHub Desktop.
Flask Github post-receive hook
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
@app.route('/post-receive-hook', methods=['GET', 'POST']) | |
def post_receive_hook(): | |
if request.method == "POST" and request.form['payload']: | |
payload = json.loads(request.form['payload']) | |
pprint(payload) | |
output = subprocess.Popen('sh /home/user/post-receive-script.sh'.split(), stdout=subprocess.PIPE).communicate()[0] | |
print output # for debugging | |
return "Hi!" | |
else: | |
abort(404) |
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
cd /home/user/project-git-repo | |
git reset --hard HEAD | |
git pull | |
touch "/etc/uwsgi/apps-available/project.ini" # restart uwsgi emperor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment