75 lines
2.0 KiB
PHP
75 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Deployer;
|
|
|
|
require_once 'recipe/common.php';
|
|
require_once 'deploy/git.php';
|
|
|
|
// Project name
|
|
set('application', 'snips');
|
|
|
|
// Project repository
|
|
set('repository', 'git@git.loken.nl:ardent/Snips.git');
|
|
|
|
// [Optional] Allocate tty for git clone. Default value is false.
|
|
set('git_tty', true);
|
|
|
|
// Shared files/dirs between deploys
|
|
set('shared_dirs', ['var/log', 'var/sessions']);
|
|
set('shared_files', ['.env.local']);
|
|
//set('writable_dirs', ['var']);
|
|
|
|
set('migrations_config', '');
|
|
set('allow_anonymous_stats', false);
|
|
|
|
set('console_options', fn() => '--no-interaction');
|
|
set('bin/console', fn() => parse('{{release_path}}/bin/console'));
|
|
|
|
// Hosts
|
|
host('snips.loken.nl')
|
|
->setRemoteUser('www-data')
|
|
->set('branch', function () {
|
|
return input()->getOption('branch') ?: 'master';
|
|
})
|
|
->set('deploy_path', '~/snips.loken.nl')
|
|
;
|
|
|
|
desc('Clear cache');
|
|
task('cache:clear', fn() => run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup'));
|
|
|
|
desc('Warm up cache');
|
|
task('cache:warmup', fn() => run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}'));
|
|
|
|
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('{{bin/php}} {{bin/console}} doctrine:migrations:migrate %s {{console_options}}', $options));
|
|
});
|
|
|
|
desc('Shows current deployed version');
|
|
task('deploy:current', function () {
|
|
$current = run('readlink {{deploy_path}}/current');
|
|
writeln("Current deployed version: $current");
|
|
});
|
|
|
|
desc('Deploy project');
|
|
task('deploy', [
|
|
'deploy:prepare',
|
|
'deploy:vendors',
|
|
'cache:clear',
|
|
'cache:warmup',
|
|
'database:migrate',
|
|
'deployment:log',
|
|
'deploy:symlink',
|
|
'deploy:unlock',
|
|
'deploy:cleanup',
|
|
'deploy:current',
|
|
]);
|
|
|
|
after('deploy', 'deploy:success');
|
|
|
|
after('deploy:failed', 'deploy:unlock'); |