Created
March 3, 2016 22:31
-
-
Save gnrfan/08242e4857481d07f828 to your computer and use it in GitHub Desktop.
Git hook for deployment in production and staging environments
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
BRANCH="$1" | |
if [ $BRANCH == "refs/heads/master" ]; then | |
echo "Deploying changes to production environment." | |
GIT_WORK_TREE=/Users/gnrfan/code/git-tests/production-environment git checkout -f | |
elif [ $BRANCH == "refs/heads/staging" ]; then | |
echo "Deploying changes to staging environment." | |
GIT_WORK_TREE=/Users/gnrfan/code/git-tests/staging-environment git checkout -f | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the server you create a repo somewhere with "git init /path/to/server/side/repo.git --bare" and then add this file in the hooks/ subfolder. You need to customize the steps for deploying in each environment as needed in your project.