Created
October 3, 2011 20:09
-
-
Save dipnlik/1260096 to your computer and use it in GitHub Desktop.
Post-receive hook to deploy projects by simply pushing to the repository
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
#!/bin/bash | |
# Don't forget to check environments and deploy paths before using this script. | |
function deploy { | |
echo "INFO: Deploying to $environment environment." | |
mkdir -p $DEPLOY_PATH | |
GIT_WORK_TREE=$DEPLOY_PATH git checkout -f $environment | |
} | |
while read oldrev newrev refname; do | |
# turns 'refs/heads/branchname' into 'branchname' | |
environment=${refname##*/} | |
case "$environment" in | |
( "production" ) | |
DEPLOY_PATH=/path/to/myproject | |
deploy ;; | |
( "homolog" ) | |
DEPLOY_PATH=/path/to/myproject-homolog | |
deploy ;; | |
( "" ) | |
echo "ERROR: Unspecified environment name. No deploy was made." ;; | |
( * ) | |
echo "WARNING: Environment '$environment' is not set up. No deploy was made." ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment