Last active
October 14, 2019 05:21
-
-
Save martincarlin87/be641908dba85bfa39c642501d0cdfb8 to your computer and use it in GitHub Desktop.
Deployer Laravel 5
This file contains 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
<?php | |
namespace Deployer; | |
require 'recipe/laravel.php'; | |
$repo_url = ''; | |
$branch = 'master'; | |
$server_url = ''; | |
$user = ''; | |
$deploy_path = ''; | |
$keep_releases = 5; | |
// Configuration | |
set('http_user', $user); | |
set('ssh_type', 'native'); | |
set('repository', $repo_url); | |
set('branch', $branch); | |
set('keep_releases', $keep_releases); | |
// Laravel shared file | |
set('shared_files', [ | |
'.env' | |
]); | |
// Laravel shared dirs | |
set('shared_dirs', [ | |
'storage' | |
]); | |
// Laravel writable dirs | |
set('writable_dirs', [ | |
'bootstrap/cache', | |
'storage', | |
'storage/app', | |
'storage/app/public', | |
'storage/framework', | |
'storage/framework/cache', | |
'storage/framework/sessions', | |
'storage/framework/views', | |
'storage/logs', | |
]); | |
// Servers | |
server('production', $server_url) | |
->user($user) | |
->set('deploy_path', $deploy_path); | |
/** | |
* Upload .env.production file as .env | |
*/ | |
task('upload:env', function () { | |
upload('.env.production', '{{deploy_path}}/shared/.env'); | |
})->desc('Environment setup'); | |
/** | |
* Upload build directory and css and js files (no .map files), and rev-manifest.json | |
*/ | |
task('upload:build_assets', function () { | |
run('mkdir {{release_path}}/public/build && mkdir {{release_path}}/public/build/css && mkdir {{release_path}}/public/build/js'); | |
upload('public/build/rev-manifest.json', '{{release_path}}/public/build/rev-manifest.json'); | |
foreach (glob("public/build/css/*.css") as $file) { | |
upload($file, '{{release_path}}/' . $file); | |
} | |
foreach (glob("public/build/js/*.js") as $file) { | |
upload($file, '{{release_path}}/' . $file); | |
} | |
})->desc('Upload build assets'); | |
desc('Deploy your project'); | |
task('deploy', [ | |
'deploy:prepare', | |
'deploy:lock', | |
'deploy:release', | |
'deploy:update_code', | |
'upload:build_assets', | |
'deploy:shared', | |
'upload:env', | |
'deploy:vendors', | |
'deploy:writable', | |
'artisan:migrate', | |
'artisan:view:clear', | |
'artisan:cache:clear', | |
'artisan:config:cache', | |
'artisan:route:cache', | |
'artisan:optimize', | |
'deploy:symlink', | |
'deploy:unlock', | |
'cleanup', | |
]); | |
after('deploy', 'success'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment