Last active
May 5, 2022 22:40
-
-
Save chrisblackwell/6f966ddf250dca56682c to your computer and use it in GitHub Desktop.
Git Post receive hook for Laravel deployment
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=/srv/www/apps.legendboats.com | |
GIT_WORK_TREE=$WEBROOT git checkout -f | |
cd $WEBROOT | |
# Check if a composer.json file is present | |
if [ -f composer.json ]; then | |
# Install or update packages specified in the lock file | |
composer install | |
fi | |
# bring the application down for maintenance. avoid the artisan command | |
touch storage/meta/down | |
echo "Application is now down." | |
# remove compiled/cache files if they exist | |
rm -f bootstrap/compiled.php | |
rm -f app/storage/meta/services.json | |
# install packages, this also regenerates the autoloader | |
composer install --no-scripts --no-dev --no-interaction --prefer-dist | |
# display the environment | |
php artisan env | |
# run any outstanding migrations | |
php artisan migrate --force | |
# optimize autoloader and compile common classes | |
php artisan optimize --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment