Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jalcine
Last active December 11, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalcine/4618184 to your computer and use it in GitHub Desktop.
Save jalcine/4618184 to your computer and use it in GitHub Desktop.
Quick copying and deployment of static files for Git.
#!/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