Last active
August 29, 2015 14:04
-
-
Save keepitsimple/9c904a72dbeeb2bcbfe4 to your computer and use it in GitHub Desktop.
Git post-receive hook on python
This file contains hidden or 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 | |
# -*- coding: UTF-8 -*- | |
#post-receive | |
import sys | |
import subprocess | |
# 1. Read STDIN (Format: "from_commit to_commit branch_name") | |
(old, new, branch) = sys.stdin.read().split() | |
# 2. Only deploy if master branch was pushed | |
if branch == 'refs/heads/master': | |
subprocess.call('date >> ~/prod-deployment.log', shell=True) | |
subprocess.call('GIT_WORK_TREE=/home/ft/app.prod git checkout master -f', shell=True) | |
subprocess.call('cd ../../app.prod;bower update', shell=True) | |
#3. Only deploy if develop branch was pushed | |
if branch == 'refs/heads/develop': | |
subprocess.call('date >> ~/dev-deployment.log', shell=True) | |
subprocess.call('GIT_WORK_TREE=/home/ft/app.dev git checkout develop -f', shell=True) | |
subprocess.call('cd ../../app.dev;bower update', shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment