Last active
December 11, 2015 14:59
-
-
Save jalcine/4618184 to your computer and use it in GitHub Desktop.
Quick copying and deployment of static files for Git.
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
#!/usr/bin/env bash | |
## @author Jacky Alcine <me@jalcine.me> | |
## @description post-recieve hook to copy ("deploy") files. | |
## | |
## @note This only checks the first ref pushed up; it doesn't iterate. | |
## Variables to be used. | |
LIVE_PATH="<your path here>" | |
LIVE_BRANCH="production" | |
# Collect the first branch to be | |
read oldrev newrev refname | |
if [ $refname = "refs/heads/$LIVE_BRANCH" ]; then | |
# Save the location of the git repository. | |
THE_GIT_DIR="$PWD"; | |
# Move into the place of action. | |
cd "$LIVE_PATH"; | |
# Export needed paths. | |
export GIT_DIR="$THE_GIT_DIR"; | |
export GIT_WORK_TREE="$LIVE_PATH"; | |
# Checkout and reset the files as needed. | |
git checkout $LIVE_BRANCH -f -v | |
git reset --hard | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment