Last active
November 26, 2021 12:10
-
-
Save akoepcke/b016101b46f77a8ab04784c1186080cb to your computer and use it in GitHub Desktop.
Deploy Laravel with Envoy
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
@servers(['web' => ['[email protected]']]) | |
@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 |
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
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
https://mydnic.be/post/how-to-deploy-laravel-application-on-dev-and-production-based-on-different-branches-with-laravel-envoy