deployer/recipe/symfony.php

72 lines
1.8 KiB
PHP
Raw Normal View History

<?php
2016-01-11 14:00:45 +07:00
namespace Deployer;
require_once __DIR__ . '/common.php';
2014-07-06 18:30:21 +04:00
2020-10-25 16:00:05 +01:00
add('recipes', ['symfony']);
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;
});
2014-07-06 22:28:15 +04:00
2020-10-25 16:00:05 +01:00
set('shared_dirs', [
'var/log',
]);
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', [
'var',
'var/cache',
'var/log',
'var/sessions',
2020-10-25 16:00:05 +01:00
]);
set('log_files', 'var/log/*.log');
set('migrations_config', '');
set('doctrine_schema_validate_config', '');
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';
if (get('migrations_config') !== '') {
$options = "$options --configuration={{release_or_current_path}}/{{migrations_config}}";
}
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
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 () {
// 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');
task('deploy', [
'deploy:prepare',
2014-07-06 22:28:15 +04:00
'deploy:vendors',
'deploy:cache:clear',
'deploy:publish',
2020-10-25 16:00:05 +01:00
]);