Created
July 11, 2022 01:11
-
-
Save sanampatel/526171b72a53fb73e96f8855c8d91a86 to your computer and use it in GitHub Desktop.
Laravel forge directory wise deployment script for laravel application
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
| cd /home/forge/<DIRECTORY_NAME> | |
| # Deploy Start Message | |
| echo "Deploying application to $FORGE_SITE_BRANCH branch at $FORGE_SITE_PATH..." | |
| # Git | |
| git pull origin $FORGE_SITE_BRANCH | |
| # Production optimized composer install | |
| $FORGE_COMPOSER install --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 | |
| $FORGE_PHP artisan down | |
| # Install NPM | |
| npm ci | |
| # Compile assets | |
| npm run prod | |
| $FORGE_PHP artisan migrate --force | |
| # Clear expired password reset tokens | |
| $FORGE_PHP artisan auth:clear-resets | |
| # Clear all laravel optimization | |
| $FORGE_PHP artisan optimize:clear | |
| # Let's restart the QUEUE | |
| # $FORGE_PHP artisan queue:restart | |
| # Restart Horizon (if installed) | |
| # $FORGE_PHP artisan horizon:terminate | |
| # Composer Autoload | |
| composer dump-autoload -o | |
| # Optimize everything back! | |
| $FORGE_PHP artisan optimize | |
| # Deployment success message | |
| echo "Deployment of $FORGE_DEPLOY_MESSAGE to $FORGE_SITE_BRANCH by $FORGE_DEPLOY_AUTHOR has been successfully!" | |
| fi | |
| # Exit maintenance mode | |
| $FORGE_PHP artisan up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment