2014-07-06 14:02:23 +04:00
|
|
|
<?php
|
2016-01-11 14:00:45 +07:00
|
|
|
namespace Deployer;
|
|
|
|
|
2014-07-12 14:23:22 +04:00
|
|
|
require_once __DIR__ . '/common.php';
|
2014-07-06 18:30:21 +04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
add('recipes', ['symfony']);
|
2016-06-05 12:58:34 -04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('symfony_version', function () {
|
|
|
|
$result = run('{{bin/console}} --version');
|
|
|
|
preg_match_all('/(\d+\.?)+/', $result, $matches);
|
|
|
|
return $matches[0][0] ?? 5.0;
|
2017-08-12 20:31:19 +03:00
|
|
|
});
|
2014-07-06 22:28:15 +04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('shared_dirs', [
|
|
|
|
'var/log',
|
|
|
|
'var/sessions']
|
|
|
|
);
|
2020-04-25 23:00:08 +03:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('shared_files', [
|
|
|
|
'.env.local.php',
|
|
|
|
'.env.local'
|
|
|
|
]);
|
2020-04-25 23:00:08 +03:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('writable_dirs', [
|
|
|
|
'var'
|
|
|
|
]);
|
2015-05-19 09:57:17 +02:00
|
|
|
|
2018-10-13 16:02:35 +02:00
|
|
|
set('migrations_config', '');
|
|
|
|
|
2021-04-03 13:05:45 +01:00
|
|
|
set('bin/console', '{{bin/php}} {{release_or_current_path}}/bin/console');
|
2014-07-06 18:30:21 +04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('console_options', function () {
|
|
|
|
return '--no-interaction';
|
|
|
|
});
|
2014-07-08 16:59:34 +04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
desc('Migrate database');
|
2014-07-06 22:28:15 +04:00
|
|
|
task('database:migrate', function () {
|
2020-10-25 16:00:05 +01:00
|
|
|
$options = '--allow-no-migration';
|
2018-10-13 16:02:35 +02:00
|
|
|
if (get('migrations_config') !== '') {
|
2021-04-03 13:05:45 +01:00
|
|
|
$options = "$options --configuration={{release_or_current_path}}/{{migrations_config}}";
|
2018-10-13 16:02:35 +02:00
|
|
|
}
|
|
|
|
|
2021-04-03 13:05:45 +01:00
|
|
|
run("cd {{release_or_current_path}} && {{bin/console}} doctrine:migrations:migrate $options {{console_options}}");
|
2020-10-25 16:00:05 +01:00
|
|
|
});
|
2014-07-08 16:59:34 +04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
desc('Clear cache');
|
|
|
|
task('deploy:cache:clear', function () {
|
|
|
|
run('{{bin/console}} cache:clear {{console_options}} --no-warmup');
|
|
|
|
});
|
|
|
|
|
|
|
|
desc('Warm up cache');
|
|
|
|
task('deploy:cache:warmup', function () {
|
|
|
|
run('{{bin/console}} cache:warmup {{console_options}}');
|
|
|
|
});
|
2014-07-08 16:59:34 +04:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
desc('Deploy project');
|
2016-04-04 17:01:55 +07:00
|
|
|
task('deploy', [
|
2020-10-08 01:53:45 +02:00
|
|
|
'deploy:prepare',
|
2014-07-06 22:28:15 +04:00
|
|
|
'deploy:vendors',
|
2017-06-29 14:51:31 +02:00
|
|
|
'deploy:cache:clear',
|
2014-07-06 22:28:15 +04:00
|
|
|
'deploy:cache:warmup',
|
2020-10-08 01:53:45 +02:00
|
|
|
'deploy:publish',
|
2020-10-25 16:00:05 +01:00
|
|
|
]);
|