Skip to content

Instantly share code, notes, and snippets.

@brcolow
Last active August 2, 2016 00:19
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 brcolow/6a52b981d155600b1ffcdf07a6087379 to your computer and use it in GitHub Desktop.
Save brcolow/6a52b981d155600b1ffcdf07a6087379 to your computer and use it in GitHub Desktop.
post-receive
#!/usr/bin/env bash
command_exists() {
declare -Ff "$1" >/dev/null;
}
error_exit() {
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 1
}
unset GIT_DIR
PROGNAME=$(basename "$0")
GIT_REPO=$HOME/repo/cryptodash
STAGING=$HOME/staging
PUBLIC_WWW=/var/www
if [ ! -d "$STAGING"/cryptodash ]; then
mkdir "${STAGING}"
cd "${STAGING}"
git clone "$GIT_REPO"
cd "${STAGING}"/cryptodash
fi
git fetch origin
git reset --hard origin/master
git clean -f -d
npm install --save-dev
gulp --production
find ${PUBLIC_WWW} -mindepth 1 -delete
cp -avr "${STAGING}"/cryptodash/build/. ${PUBLIC_WWW}
cp post-receive "${GIT_REPO}"/hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment