deployer/recipe/symfony4.php

49 lines
1.2 KiB
PHP
Raw Normal View History

2018-03-05 20:22:30 +07:00
<?php
namespace Deployer;
require_once __DIR__ . '/common.php';
2018-03-05 20:22:30 +07:00
2018-04-18 11:37:43 +07:00
set('shared_dirs', ['var/log', 'var/sessions']);
set('shared_files', ['.env.local.php', '.env.local']);
2018-03-05 20:22:30 +07:00
set('writable_dirs', ['var']);
set('migrations_config', '');
2018-03-05 20:22:30 +07:00
set('bin/console', function () {
return parse('{{release_path}}/bin/console');
});
set('console_options', function () {
return '--no-interaction';
2018-03-05 20:22:30 +07:00
});
desc('Migrate database');
task('database:migrate', function () {
$options = '--allow-no-migration';
if (get('migrations_config') !== '') {
$options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options);
}
run(sprintf('cd {{release_path}} && {{bin/php}} {{bin/console}} doctrine:migrations:migrate %s {{console_options}}', $options));
2018-03-05 20:22:30 +07:00
});
2018-04-18 06:13:53 +02:00
desc('Clear cache');
task('deploy:cache:clear', function () {
run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup');
2018-04-18 06:13:53 +02:00
});
desc('Warm up cache');
task('deploy:cache:warmup', function () {
run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}');
2018-04-18 06:13:53 +02:00
});
2018-03-05 20:22:30 +07:00
desc('Deploy project');
task('deploy', [
'deploy:prepare',
2018-03-05 20:22:30 +07:00
'deploy:vendors',
2018-04-18 06:13:53 +02:00
'deploy:cache:clear',
'deploy:cache:warmup',
'deploy:publish',
2018-03-05 20:22:30 +07:00
]);
after('deploy', 'success');