Skip to content

Commit

Permalink
Anpassungen deploy.php
Browse files Browse the repository at this point in the history
- Flexiblere Pfade
- Zweistufiges Deployment (lokal bauen, dann auf die Server verteilen)
  • Loading branch information
gharlan committed Sep 5, 2017
1 parent c0bc9fb commit b923dcc
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Siehe dazu:
Die folgende `.gitignore` hat sich als Basis bewährt bei Nutzung von deployer:

```
/.build
/media/*
!/media/.redaxo
/redaxo/cache/*
Expand Down
110 changes: 96 additions & 14 deletions deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,38 @@
}

set('base_dir', $baseDir);
set('cache_dir', '{{base_dir}}redaxo/cache');
set('data_dir', '{{base_dir}}redaxo/data');
set('src_dir', '{{base_dir}}redaxo/src');

set('bin/console', '{{base_dir}}redaxo/bin/console');

set('shared_dirs', [
'{{base_dir}}media',
'{{base_dir}}redaxo/data/addons/cronjob',
'{{base_dir}}redaxo/data/addons/phpmailer',
'{{base_dir}}redaxo/data/core',
'{{data_dir}}/addons/cronjob',
'{{data_dir}}/addons/phpmailer',
'{{data_dir}}/addons/yform',
'{{data_dir}}/core',
]);

set('writable_dirs', [
'{{base_dir}}assets',
'{{base_dir}}media',
'{{base_dir}}redaxo/cache',
'{{base_dir}}redaxo/data',
'{{cache_dir}}',
'{{data_dir}}',
]);

set('copy_dirs', [
'{{base_dir}}assets',
'{{src_dir}}',
]);

set('clear_paths', [
'gulpfile.js',
'node_modules',
'deploy.php',
'package.json',
'yarn.lock',
]);

set('ssh_type', 'native');
Expand All @@ -37,24 +56,87 @@
* Tasks
*/

task('deploy', [
task('build', function () {
set('deploy_path', getcwd().'/.build');
set('keep_releases', 1);

invoke('build:info');
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');

This comment has been minimized.

Copy link
@staabm

staabm Dec 8, 2017

Contributor

will man in einem regulären build wirklich dass deployer autom. änderungen reinholt?
oder will man eher selbst die änderungen vorher reingeholt haben und dann dass deployer genau den stand baut der vorliegt, ohne ihn zu verändert?

invoke('build:assets');
invoke('deploy:clear_paths');
invoke('deploy:symlink');
invoke('cleanup');
})->shallow()->local();

task('release', [
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:clear_paths',
'deploy:copy_dirs',
'upload',
'deploy:shared',
'deploy:writable',
'database:migration',
'deploy:symlink',
'deploy:unlock',
'cleanup',
])->desc('Deploy project');
'success',
]);

task('deploy', [
'build',
'release',
]);

task('build:info', function () {
$what = '';
$branch = get('branch');

if (!empty($branch)) {
$what = "<fg=magenta>$branch</fg=magenta>";
}

if (input()->hasOption('tag') && !empty(input()->getOption('tag'))) {
$tag = input()->getOption('tag');
$what = "tag <fg=magenta>$tag</fg=magenta>";
} elseif (input()->hasOption('revision') && !empty(input()->getOption('revision'))) {
$revision = input()->getOption('revision');
$what = "revision <fg=magenta>$revision</fg=magenta>";
}

if (empty($what)) {
$what = '<fg=magenta>HEAD</fg=magenta>';
}

writeln("✂ Building $what on <fg=cyan>{{hostname}}</fg=cyan>");
})->shallow()->setPrivate();

task('build:assets', function () {
cd('{{release_path}}');

if (get('yarn')) {
run('yarn');
}

if (get('gulp')) {
run('gulp {{gulp_options}}');
}
});

task('upload', function () {
upload(getcwd().'/.build/current/', '{{release_path}}', [
'options' => ['--exclude=".git/"', '--delete'],
]);
});

task('database:migration', function () {
run('cd {{release_path}}/{{base_dir}} && redaxo/bin/console ydeploy:migrate');
cd('{{release_path}}');

run('{{bin/console}} ydeploy:migrate');

run('cd {{release_path}}/{{base_dir}} && if [[ $(redaxo/bin/console list --raw | grep developer:sync) ]]; then redaxo/bin/console developer:sync; fi');
})->desc('Migrate database');
run('if [[ $({{bin/console}} list --raw | grep developer:sync) ]]; then {{bin/console}} developer:sync; fi');
});

after('deploy', 'success');
after('deploy:failed', 'deploy:unlock');

This comment has been minimized.

Copy link
@staabm

staabm Dec 8, 2017

Contributor

du lock'st nirgends, warum unlock?

0 comments on commit b923dcc

Please sign in to comment.