-
-
Save btbytes/d4f2324396048b437803 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# A github post-receive hook handler, runs some shell command on each HTTP POST to PORT. | |
# github-listener.py PORT 'SOME SHELL COMMAND' | |
import sys | |
from subprocess import * | |
from flask import Flask | |
def system(cmd): | |
return ''.join(Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=True).communicate()) | |
app = Flask(__name__) | |
@app.route("/", methods=['POST']) | |
def post(): | |
cmd = 'cd /home/pradeep/web/www.konkanirecipes.com/site && git pull origin master && git push deploy master' | |
ret = system(cmd) | |
return 'ok' | |
if __name__ == "__main__": | |
app.run(host='0.0.0.0', port=8876, debug=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment