deployer/recipe/symfony.php

64 lines
1.4 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',
'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'
]);
set('migrations_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
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';
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
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');
task('deploy', [
'deploy:prepare',
2014-07-06 22:28:15 +04:00
'deploy:vendors',
'deploy:cache:clear',
2014-07-06 22:28:15 +04:00
'deploy:cache:warmup',
'deploy:publish',
2020-10-25 16:00:05 +01:00
]);