Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
new laravel post receive hook with gulp, etc in it
#!/bin/sh
# from - See more at:
# http://www.codyjbutz.com/blog/deploying-laravel-5-using-git-hooks#sthash.6YmBWVjW.dpuf
WEBDIRECTORY=/var/www/simplecourt.com
GITDIRECTORY=/home/deployer/repos/simplecourt.git
USER=deployer
GROUP=www-data
#set HOME so that git uses the correct ~/.git/ folder
HOME="$(getent passwd $USER | awk -F ':' '{print $6}')"
echo "Pushing $COMMIT to repository."
echo "Suspending Application and fixing permissions"
cd $WEBDIRECTORY
chown -R $USER:$GROUP .
php artisan down
echo "Checking out latest"
cd $GITDIRECTORY
# Only need this if our remote is set up to ssh in as root
#sudo -u $USER bash << EOF
#echo "Switched to "
#whoami
GIT_WORK_TREE=$WEBDIRECTORY git fetch origin master;
GIT_WORK_TREE=$WEBDIRECTORY git checkout -f;
cd $WEBDIRECTORY
echo "Set up prod env"
cp -f .env.prod .env
## Uncomment bellow if we start needing to run gulp at deploy time
#echo "Prep Packages"
#npm install
#echo "Running Gulp tasks"
#gulp
#This can only be run if sudo / root
#echo "Updating composer (Optional)"
#composer self-update
echo "Running composer install"
composer install --optimize-autoloader --no-dev
echo "Running outstanding migrations"
php artisan migrate --force
echo "Clearing Cache"
php artisan cache:clear
php artisan config:cache
echo "Bringing Application Online"
php artisan up
# Only need this if our remote is set up to ssh in as root
#EOF
#echo "Back to Origin User"
echo "Ensuring permissions are correct"
chmod -R g+w $WEBDIRECTORY/storage/framework/*
chmod -R g+w $WEBDIRECTORY/storage/logs/*
echo "Deployment finished!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.