Skip to content

Instantly share code, notes, and snippets.

@henryonsoftware
Last active July 16, 2024 06:03
Show Gist options
  • Save henryonsoftware/e218192d7dd1b30a06aa14de42363e59 to your computer and use it in GitHub Desktop.
Save henryonsoftware/e218192d7dd1b30a06aa14de42363e59 to your computer and use it in GitHub Desktop.
Laravel deploy script on Forge
# Go inside the site directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
$FORGE_PHP artisan down
git pull origin $FORGE_SITE_BRANCH
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
if [ -f artisan ]; then
# Run database migrations
$FORGE_PHP artisan migrate --force
# Clear caches
$FORGE_PHP artisan cache:clear
# Clear and cache config
$FORGE_PHP artisan config:cache
# Clear and cache routes
$FORGE_PHP artisan route:cache
# Clear and cache views
$FORGE_PHP artisan view:cache
# Restart queue runner
$FORGE_PHP artisan queue:restart
fi
# Install node dependencies and build
npm ci
npm run build
# 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