Skip to content

Instantly share code, notes, and snippets.

@mnshankar
Last active July 24, 2016 22:20
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mnshankar/9619606 to your computer and use it in GitHub Desktop.
Save mnshankar/9619606 to your computer and use it in GitHub Desktop.
post-receive hook for git deploy (Laravel 4)
#!/bin/sh
WEBROOT=/var/www/domain.com/project
GIT_WORK_TREE=$WEBROOT git checkout -f
#change directory to the project dir
cd $WEBROOT
rm -f storage/cache/*
echo 'cache cleared'
rm -f storage/views/*
echo 'views cleared'
# Check if a composer.json file is present
if [ -f composer.json ]; then
# Detect composer binary
if which composer >/dev/null; then
composer='composer'
elif which composer.phar >/dev/null; then
composer='composer.phar'
else
# Install composer
curl -s http://getcomposer.org/installer | php >/dev/null
composer='php composer.phar'
fi
# Install or update packages specified in the lock file
$composer install
fi
# migrate database if required
php artisan migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment