Skip to content

Instantly share code, notes, and snippets.

@anlisha-maharjan
Created January 8, 2023 16:21
Show Gist options
  • Save anlisha-maharjan/bd244b5f20920702ed0c0ee105058347 to your computer and use it in GitHub Desktop.
Save anlisha-maharjan/bd244b5f20920702ed0c0ee105058347 to your computer and use it in GitHub Desktop.
Laravel Deployment Script - To pull latest version of code and install composer dependencies and run migrations.
#!/bin/bash
set -e
echo "Deployment started ..."
# Enter maintenance mode or return true
# if already is in maintenance mode
(php artisan down) || true
# Pull the latest version of the app
git pull origin master
# Install composer dependencies
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
# Clear the old cache
php artisan clear-compiled
# Recreate cache
php artisan optimize
# Run database migrations
php artisan migrate --force
# Exit maintenance mode
php artisan up
echo "Deployment finished!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment