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',
|
2021-04-16 11:13:58 +02:00
|
|
|
]);
|
2020-04-25 23:00:08 +03:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('shared_files', [
|
|
|
|
'.env.local'
|
|
|
|
]);
|
2020-04-25 23:00:08 +03:00
|
|
|
|
2020-10-25 16:00:05 +01:00
|
|
|
set('writable_dirs', [
|
2022-03-03 21:39:28 +01:00
|
|
|
'var',
|
|
|
|
'var/cache',
|
|
|
|
'var/log',
|
|
|
|
'var/sessions',
|
2020-10-25 16:00:05 +01:00
|
|
|
]);
|
2015-05-19 09:57:17 +02:00
|
|
|
|
2023-04-10 11:27:30 +02:00
|
|
|
set('log_files', 'var/log/*.log');
|
|
|
|
|
2018-10-13 16:02:35 +02:00
|
|
|
set('migrations_config', '');
|
|
|
|
|
2022-01-15 21:20:50 +01:00
|
|
|
set('doctrine_schema_validate_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
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Migrates 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
|
|
|
|
2022-01-15 21:20:50 +01:00
|
|
|
desc('Validate the Doctrine mapping files');
|
|
|
|
task('doctrine:schema:validate', function () {
|
|
|
|
run("cd {{release_or_current_path}} && {{bin/console}} doctrine:schema:validate {{doctrine_schema_validate_config}} {{console_options}}");
|
|
|
|
});
|
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Clears cache');
|
2020-10-25 16:00:05 +01:00
|
|
|
task('deploy:cache:clear', function () {
|
2021-07-15 22:20:44 +02:00
|
|
|
// composer install scripts usually clear and warmup symfony cache
|
|
|
|
// so we only need to do it if composer install was run with --no-scripts
|
|
|
|
if (false !== strpos(get('composer_options', ''), '--no-scripts')) {
|
|
|
|
run('{{bin/console}} cache:clear {{console_options}}');
|
|
|
|
}
|
2020-10-25 16:00:05 +01:00
|
|
|
});
|
2014-07-08 16:59:34 +04:00
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Deploys 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',
|
2020-10-08 01:53:45 +02:00
|
|
|
'deploy:publish',
|
2020-10-25 16:00:05 +01:00
|
|
|
]);
|