Skip to content

Instantly share code, notes, and snippets.

@epixian
Last active September 12, 2019 14:20
Show Gist options
  • Save epixian/0e86069202bb8333673296c917a7105a to your computer and use it in GitHub Desktop.
Save epixian/0e86069202bb8333673296c917a7105a to your computer and use it in GitHub Desktop.
A deployment script for Laravel projects hosted on Laravel Forge
function deploy() {
# install composer dependencies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev &&
# install node modules
npm clean-install &&
# build assets using Laravel Mix
npm run production ||
return $?
}
# Change to the project directory
cd /home/forge/epixian.com
# Turn on maintenance mode
php artisan down
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin master
# trigger deployment steps
deploy
# Reload PHP FPM service
echo "" | sudo -S service php7.3-fpm reload
# Run database migrations
php artisan migrate --force
# Clear caches
php artisan cache:clear
# Clear expired password reset tokens
php artisan auth:clear-resets
# Clear and cache routes
# php artisan route:clear
# php artisan route:cache
# Clear and cache config
php artisan config:clear
php artisan config:cache
# Turn off maintenance mode
php artisan up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment