-
-
Save npostman/477319bb8b4108c29c655fef4c11ea6c to your computer and use it in GitHub Desktop.
Laravel deploy script
This file contains hidden or 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
# Change to the project directory | |
cd $FORGE_SITE_PATH | |
# Turn on maintenance mode | |
$FORGE_PHP artisan down --render='errors::503' --retry=30 || true | |
# Pull the latest changes from the git repository | |
# git reset --hard | |
# git clean -df | |
git pull origin $FORGE_SITE_BRANCH | |
# Install/update composer dependecies | |
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader --no-dev | |
( flock -w 10 9 || exit 1 | |
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock | |
# Clear expired password reset tokens | |
#$FORGE_PHP artisan auth:clear-resets | |
# Clear and cache routes | |
$FORGE_PHP artisan route:cache | |
# Clear and cache config | |
$FORGE_PHP artisan config:cache | |
# Clear and cache views | |
$FORGE_PHP artisan view:cache | |
# Run database migrations | |
if [ -f artisan ]; then | |
$FORGE_PHP artisan migrate --force | |
fi | |
touch hash_resources.txt | |
HASH_RESOURCES="$(cat hash_resources.txt)" | |
find ./resources/sass ./resources/js ./webpack.mix.js ./package-lock.json -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum > hash_resources.txt | |
HASH_NEW_RESOURCES="$(cat hash_resources.txt)" | |
if [ "$HASH_RESOURCES" != "$HASH_NEW_RESOURCES" ]; then | |
echo "Running: npm" | |
npm ci | |
npm run prod | |
rm -rf node_modules | |
else | |
echo "Skipped: npm run prod" | |
fi | |
# Turn off maintenance mode | |
$FORGE_PHP artisan up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment