Skip to content

Instantly share code, notes, and snippets.

@itsme-renee
Created May 14, 2013 13:54
Show Gist options
  • Save itsme-renee/5576044 to your computer and use it in GitHub Desktop.
Save itsme-renee/5576044 to your computer and use it in GitHub Desktop.
git post receive hook example
#!/bin/bash
##change website.com to your website
APP_PATH=/var/www/website.com
exit_with_error() {
echo "[DEPLOY] !!!!!!!!!!!!!!!!!!!! An error has occurred !!!!!!!!!!!!!!!!!!!!!!!"
exit 1
}
# Initial directory is .git, so go to the working copy directory
mkdir -p ${APP_PATH}
cd ${APP_PATH}
echo "**********************************************************************"
echo " Deploying application... "
echo "**********************************************************************"
echo "[DEPLOY] - * Updating application working tree"
env -i git add .
env -i git reset --hard || exit_with_error
env -i git pull origin master
echo "[DEPLOY] - * Updating git submodules"
env -i git submodule update --init
echo "[DEPLOY] - * Running database migrations"
php oil r migrate
echo "[Deploy] - * Running database migrations for package=sentry"
php oil refine migrate --packages=sentry
echo "[DEPLOY] - * Successfully deployed application to ${APP_PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment