Created
March 28, 2014 23:11
-
-
Save bad-mushroom/9844887 to your computer and use it in GitHub Desktop.
post-receive hook for deploying site based on branch. "master" is pushed to the production site, "development" to the test site.
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 '--- --- --- --- --- --- --- --- --- --- ---' | |
echo 'Deploying site...' | |
echo '--- --- --- --- --- --- --- --- --- --- ---' | |
if ! [ -t 0 ]; then | |
read -a ref | |
fi | |
IFS='/' read -ra REF <<< "${ref[2]}" | |
branch="${REF[2]}" | |
# Master Branch | |
if [ "master" == "$branch" ]; then | |
git --work-tree=/path/to/production/site checkout -f $branch | |
echo 'Changes pushed to production site' | |
fi | |
# Development Branch | |
if [ "development" == "$branch" ]; then | |
git --work-tree=/path/to/test/site checkout -f $branch | |
echo 'Changes pushed to test site' | |
fi | |
echo '--- --- --- --- --- --- --- --- --- --- ---' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much!