Skip to content

Instantly share code, notes, and snippets.

@joparara
Forked from ChrisHardie/deploy-laravel-app.sh
Created May 12, 2024 03:36
Show Gist options
  • Save joparara/ef0c560ac7e3601e1bf047b4d73a4841 to your computer and use it in GitHub Desktop.
Save joparara/ef0c560ac7e3601e1bf047b4d73a4841 to your computer and use it in GitHub Desktop.
Simple Bash script to deploy a Laravel App
#!/bin/bash
version=`php artisan --version`
if [[ ${version} != *"Laravel Framework"* ]]; then
echo "Not a Laravel app, exiting."
exit;
fi
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin main
# Install/update composer dependecies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
# Run database migrations
php artisan migrate --force
# Clear caches
php artisan cache:clear
# Clear and cache routes
php artisan route:cache
# Clear and cache config
php artisan config:cache
# Clear and cache views
php artisan view: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