Created
June 1, 2016 23:28
-
-
Save PLaRoche/365dcf0d4196c73c1ea24165cc191c31 to your computer and use it in GitHub Desktop.
new laravel post receive hook with gulp, etc in it
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
#!/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