2015-05-18 11:26:59 +07:00
|
|
|
<?php
|
2016-01-11 12:51:59 +07:00
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
2015-05-18 11:26:59 +07:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
2016-11-19 14:37:52 +07:00
|
|
|
/*
|
|
|
|
* This recipe supports Laravel 5.1+, for older versions, please read the documentation https://github.com/deployphp/docs
|
|
|
|
*/
|
2015-05-18 11:26:59 +07:00
|
|
|
|
2016-01-11 14:00:45 +07:00
|
|
|
namespace Deployer;
|
|
|
|
|
2015-05-18 11:26:59 +07:00
|
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
|
|
|
|
// Laravel shared dirs
|
2016-11-19 14:37:52 +07:00
|
|
|
set('shared_dirs', [
|
|
|
|
'storage'
|
|
|
|
]);
|
2015-05-18 11:26:59 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
// Laravel shared file
|
|
|
|
set('shared_files', [
|
|
|
|
'.env'
|
|
|
|
]);
|
2015-05-28 00:41:52 +07:00
|
|
|
|
2015-05-18 11:26:59 +07:00
|
|
|
// Laravel writable dirs
|
2016-11-19 14:37:52 +07:00
|
|
|
set('writable_dirs', [
|
|
|
|
'bootstrap/cache',
|
|
|
|
'storage',
|
|
|
|
'storage/app',
|
|
|
|
'storage/app/public',
|
|
|
|
'storage/framework',
|
|
|
|
'storage/framework/cache',
|
|
|
|
'storage/framework/sessions',
|
|
|
|
'storage/framework/views',
|
|
|
|
'storage/logs',
|
|
|
|
]);
|
2015-05-18 11:26:59 +07:00
|
|
|
|
2016-04-13 10:32:48 +07:00
|
|
|
/**
|
|
|
|
* Helper tasks
|
|
|
|
*/
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Disable maintenance mode');
|
2016-04-13 10:32:48 +07:00
|
|
|
task('artisan:up', function () {
|
2016-10-11 18:08:55 +02:00
|
|
|
$output = run('if [ -f {{deploy_path}}/current/artisan ]; then {{bin/php}} {{deploy_path}}/current/artisan up; fi');
|
2016-10-11 14:50:17 +02:00
|
|
|
writeln('<info>' . $output . '</info>');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-04-13 10:32:48 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Enable maintenance mode');
|
2016-04-13 10:32:48 +07:00
|
|
|
task('artisan:down', function () {
|
2016-10-11 18:08:55 +02:00
|
|
|
$output = run('if [ -f {{deploy_path}}/current/artisan ]; then {{bin/php}} {{deploy_path}}/current/artisan down; fi');
|
2016-11-19 15:13:32 +07:00
|
|
|
writeln('<info>' . $output . '</info>');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-04-13 10:32:48 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan migrate');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:migrate', function () {
|
2016-11-19 15:13:32 +07:00
|
|
|
run('{{bin/php}} {{release_path}}/artisan migrate --force');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan migrate:rollback');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:migrate:rollback', function () {
|
2016-10-11 14:50:17 +02:00
|
|
|
$output = run('{{bin/php}} {{release_path}}/artisan migrate:rollback --force');
|
2016-05-18 12:28:00 +07:00
|
|
|
writeln('<info>' . $output . '</info>');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan migrate:status');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:migrate:status', function () {
|
2016-10-11 14:50:17 +02:00
|
|
|
$output = run('{{bin/php}} {{release_path}}/artisan migrate:status');
|
2016-05-18 12:28:00 +07:00
|
|
|
writeln('<info>' . $output . '</info>');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan db:seed');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:db:seed', function () {
|
2016-10-11 14:50:17 +02:00
|
|
|
$output = run('{{bin/php}} {{release_path}}/artisan db:seed --force');
|
2016-05-18 12:28:00 +07:00
|
|
|
writeln('<info>' . $output . '</info>');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan cache:clear');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:cache:clear', function () {
|
2016-11-19 15:13:32 +07:00
|
|
|
run('{{bin/php}} {{release_path}}/artisan cache:clear');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan config:cache');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:config:cache', function () {
|
2016-11-19 15:13:32 +07:00
|
|
|
run('{{bin/php}} {{release_path}}/artisan config:cache');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Execute artisan route:cache');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('artisan:route:cache', function () {
|
2016-11-19 15:13:32 +07:00
|
|
|
run('{{bin/php}} {{release_path}}/artisan route:cache');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2016-11-24 10:27:18 -02:00
|
|
|
desc('Execute artisan view:clear');
|
|
|
|
task('artisan:view:clear', function () {
|
|
|
|
run('{{bin/php}} {{release_path}}/artisan view:clear');
|
|
|
|
});
|
|
|
|
|
2016-11-25 14:58:13 +07:00
|
|
|
desc('Execute artisan optimize');
|
|
|
|
task('artisan:optimize', function () {
|
|
|
|
run('{{bin/php}} {{release_path}}/artisan optimize');
|
|
|
|
});
|
|
|
|
|
2017-02-13 11:32:21 +02:00
|
|
|
desc('Execute artisan queue:restart');
|
|
|
|
task('artisan:queue:restart', function () {
|
|
|
|
run('{{bin/php}} {{release_path}}/artisan queue:restart');
|
|
|
|
});
|
|
|
|
|
2016-05-18 12:28:00 +07:00
|
|
|
/**
|
|
|
|
* Task deploy:public_disk support the public disk.
|
|
|
|
* To run this task automatically, please add below line to your deploy.php file
|
2016-11-19 14:37:52 +07:00
|
|
|
*
|
|
|
|
* before('deploy:symlink', 'deploy:public_disk');
|
|
|
|
*
|
2016-05-18 12:28:00 +07:00
|
|
|
* @see https://laravel.com/docs/5.2/filesystem#configuration
|
|
|
|
*/
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Make symlink for public disk');
|
2016-05-18 12:28:00 +07:00
|
|
|
task('deploy:public_disk', function () {
|
|
|
|
// Remove from source.
|
|
|
|
run('if [ -d $(echo {{release_path}}/public/storage) ]; then rm -rf {{release_path}}/public/storage; fi');
|
|
|
|
|
|
|
|
// Create shared dir if it does not exist.
|
|
|
|
run('mkdir -p {{deploy_path}}/shared/storage/app/public');
|
|
|
|
|
|
|
|
// Symlink shared dir to release dir
|
2016-11-05 13:40:12 +07:00
|
|
|
run('{{bin/symlink}} {{deploy_path}}/shared/storage/app/public {{release_path}}/public/storage');
|
2016-11-19 14:37:52 +07:00
|
|
|
});
|
2016-05-18 12:28:00 +07:00
|
|
|
|
2015-05-18 11:26:59 +07:00
|
|
|
/**
|
|
|
|
* Main task
|
|
|
|
*/
|
2016-11-19 14:37:52 +07:00
|
|
|
desc('Deploy your project');
|
2016-04-04 17:01:55 +07:00
|
|
|
task('deploy', [
|
2015-05-18 11:26:59 +07:00
|
|
|
'deploy:prepare',
|
2016-11-05 12:56:53 +07:00
|
|
|
'deploy:lock',
|
2015-05-18 11:26:59 +07:00
|
|
|
'deploy:release',
|
|
|
|
'deploy:update_code',
|
2015-05-20 22:39:24 +03:00
|
|
|
'deploy:shared',
|
2016-04-13 10:32:48 +07:00
|
|
|
'deploy:vendors',
|
|
|
|
'deploy:writable',
|
2016-11-24 10:27:18 -02:00
|
|
|
'artisan:view:clear',
|
2016-05-18 12:28:00 +07:00
|
|
|
'artisan:cache:clear',
|
|
|
|
'artisan:config:cache',
|
2017-02-13 11:32:21 +02:00
|
|
|
'artisan:queue:restart',
|
2016-11-25 14:58:13 +07:00
|
|
|
'artisan:optimize',
|
|
|
|
'deploy:symlink',
|
|
|
|
'deploy:unlock',
|
|
|
|
'cleanup',
|
2016-11-19 14:37:52 +07:00
|
|
|
]);
|
2015-05-18 11:26:59 +07:00
|
|
|
|
|
|
|
after('deploy', 'success');
|