Last active
April 28, 2017 18:43
-
-
Save lucassmacedo/17065b942fb9600d339f24578687f27c to your computer and use it in GitHub Desktop.
post-receive hook for git deploy (Laravel 5)
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 | |
WEBROOT=~/laravelapp | |
GIT_WORK_TREE=$WEBROOT git checkout -f | |
#change directory to the project dir | |
cd $WEBROOT | |
# 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 --dev | |
fi | |
# migrate database if required | |
php artisan cache:clear | |
php artisan view:clear | |
php artisan optimize | |
rm -rf ~/public_html | |
ln -s $WEBROOT/public ~/public_html | |
chown -R $(users):$(users) . | |
find . -type d -exec chmod 0755 {} \; && find . -type f -exec chmod 0644 {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Eu incluiria um php artisan optimize pra fazer um composer dumpautoload -o e otimizar o autoload do composer. No composer install incluiria um - - no-dev caso seja em production para nao incluir libs utilizadas apenas em desenv (no composer.json estas libs devem estar no require-dev).