Created
November 21, 2014 09:33
-
-
Save andrepadez/3fbffe59cccf7901f1b2 to your computer and use it in GitHub Desktop.
git post-receive hook for deployment by branch
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
#!/bin/bash | |
echo "Running Post-Receive hook" | |
while read oldrev newrev ref ; do | |
if [ "$ref" == "refs/heads/master" ]; then | |
GIT_WORK_TREE=/home/josh/production/sonimcampaign git checkout -f | |
echo 'branch master deployed to live' | |
elif [ "$ref" == "refs/heads/staging" ]; then | |
git symbolic-ref HEAD refs/heads/staging | |
GIT_WORK_TREE=/home/josh/staging/sonimcampaign git checkout -f | |
git symbolic-ref HEAD refs/heads/master | |
echo "branch staging deployed to staging" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment