From 33b9a9e8b4dfbeacecf5a1a9fd54328d7fdf7ee2 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 6 Nov 2012 11:09:07 -0500 Subject: [PATCH] post-receive: Add support for deploying to staging server. After this commit, we're tracking two branches: "master" and "prod". Pushed to "prod" deploy to production, while pushes to "master" deploy to the staging server. (imported from commit 6ce429a1d6f606fb6136341dc393d93fd1228a21) --- tools/post-receive | 11 +++++++---- tools/update-deployment | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/post-receive b/tools/post-receive index 0052f650fb..a565c6b99a 100755 --- a/tools/post-receive +++ b/tools/post-receive @@ -41,8 +41,8 @@ def check_output(*popenargs, **kwargs): return output subprocess.check_output = check_output -def update_deployment(oldrev, newrev, refname): - subprocess.check_call(["ssh", "humbughq.com", "--", "env", "-u", "GIT_DIR", +def update_deployment(server, oldrev, newrev, refname): + subprocess.check_call(["ssh", server, "--", "env", "-u", "GIT_DIR", "/home/humbug/humbug/tools/update-deployment", oldrev, newrev, refname]) @@ -91,6 +91,9 @@ def send_bot_message(oldrev, newrev, refname): for ln in sys.stdin: oldrev, newrev, refname = ln.strip().split() - if refname in ["refs/heads/master", "refs/heads/test-post-receive"]: + if refname in ["refs/heads/prod"]: send_bot_message(oldrev, newrev, refname) - update_deployment(oldrev, newrev, refname) + update_deployment("humbughq.com", oldrev, newrev, "origin/prod") + elif refname in ["refs/heads/master", "refs/heads/test-post-receive"]: + send_bot_message(oldrev, newrev, refname) + update_deployment("staging.humbughq.com", oldrev, newrev, "origin/master") diff --git a/tools/update-deployment b/tools/update-deployment index 83078e57b0..d876fac55f 100755 --- a/tools/update-deployment +++ b/tools/update-deployment @@ -32,7 +32,7 @@ if len(sys.argv) > 1: refname = sys.argv[3] subprocess.check_call(["git", "fetch"], stdout=open('/dev/null', 'w')) -subprocess.check_call(["git", "reset", "--hard", "origin/master"], stdout=open('/dev/null', 'w')) +subprocess.check_call(["git", "reset", "--hard", refname], stdout=open('/dev/null', 'w')) #subprocess.check_call(["python", "manage.py", "syncdb"], stdout=open('/dev/null', 'w')) # Restart the FastCGI process, which is running in a shell loop in screen.