Skip to content

Instantly share code, notes, and snippets.

@dinhquochan
Created June 21, 2022 04:20
Show Gist options
  • Save dinhquochan/b82521d0bc741e9f33f0fa3c23b422ec to your computer and use it in GitHub Desktop.
Save dinhquochan/b82521d0bc741e9f33f0fa3c23b422ec to your computer and use it in GitHub Desktop.
Laravel Deploy Script (without assets build)
#!/usr/bin/env bash
# default branch name of git repository
$BRANCH="main"
set -e
# ensure current directory is root of repository.
if [ ! -f artisan ]
then
echo "Please run this script in your root of repository."
exit 1
fi
## make website in maintaince mode
php artisan down
## pull latest source code, clean up staged area
git reset --hard
git clean -df
git pull origin $BRANCH
## install latest dependencies from composer.lock
composer install --no-dev --no-ansi --no-interaction --prefer-dist
## generates encrypt key, if exists, ignore in quiet
php artisan key:generate -q
## run all migrations, force in production mode
php artisan migrate --force --step
## cleanup caches, autoload files
php artisan optimize:clear
# caching some stuff
php artisan view:cache
php artisan config:cache
php artisan route:cache
php artisan event:cache
# restart horizon
php artisan horizon:terminate
# well, remove all old log files
rm -rf storage/logs/laravel*
# turn on, now!
php artisan up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment