Skip to content

Instantly share code, notes, and snippets.

@akoepcke
Last active November 26, 2021 12:10
Show Gist options
  • Save akoepcke/b016101b46f77a8ab04784c1186080cb to your computer and use it in GitHub Desktop.
Save akoepcke/b016101b46f77a8ab04784c1186080cb to your computer and use it in GitHub Desktop.
Deploy Laravel with Envoy
@servers(['web' => ['user@my-server.com']])
@setup
$env = isset($env) ? $env : 'dev';
if ($env === 'dev') {
$dir = '/var/www/html/dev/my-laravel-app';
} else if ($env === 'production') {
$dir = '/var/www/html/my-laravel-app';
}
@endsetup
@story('deploy')
down
pull_changes
run_composer
migrate
clear_cache
build_assets
up
@endstory
@task('pull_changes')
cd {{ $dir }}
echo 'Retrieve Changes'
git reset --hard HEAD;git clean -df
git pull
@endtask
@task('run_composer')
cd {{ $dir }}
echo "Starting deployment"
composer install
@endtask
@task('migrate')
cd {{ $dir }}
echo "Migrating"
php artisan migrate --force
@endtask
@task('clear_cache')
cd {{ $dir }}
echo "Clear Cache"
php artisan cache:clear
echo "Restart Queue"
php artisan queue:restart
@endtask
@task('build_assets')
cd {{ $dir }}
echo "Build Assets"
yarn
npm run prod
@endtask
@task('storage')
php artisan storage:link
@endtask
@task('down')
php artisan down --refresh=15 --render="errors::503"
@endtask
@task('up')
php artisan up
@endtask
Deploy on dev:
envoy run deploy
Deploy on production:
envoy run deploy --env=production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment