-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Branch settings in hosts.yml are ignored #1946
Comments
How can I help to fix this issue? |
Hi, we need to take a closer look at how branch options is overriding each other from different places. |
Also, I think here |
Is it possible to use |
Hmm. B n ever was trying to use it as you describe. |
As far as I understand is the usecase of I try to add Do you have any example for these? The docs aren't helping much. I have to basically build it locally and push it to the hosts (as in the I've testet: typo3.example.com:
hostname: example.com
user: typo3
stage: production
roles: build, app
branch: master
deploy_path: "~/"
typo3-staging.example.com:
hostname: example.com
user: typo3-staging
stage: staging
roles: build, app
branch: develop
deploy_path: "~/" deploy.php <?php
namespace Deployer;
require_once 'recipe/common.php';
/**
* Setup
*/
inventory('hosts.yml');
localhost()
->roles('build');
set('allow_anonymous_stats', false);
set('typo3_webroot', 'public');
set('deploy_path_local', '/tmp');
set('release_name', date('Y-m-d_H-i-s'));
/*
* Repository
*/
set('repository', 'git@some.com/location.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
/*
* Shared files / directories
*/
set('shared_files', [
'{{typo3_webroot}}/typo3conf/LocalConfiguration.php',
'{{typo3_webroot}}/.htaccess',
'.env',
]);
set('shared_dirs', [
'{{typo3_webroot}}/fileadmin',
'{{typo3_webroot}}/typo3temp',
'{{typo3_webroot}}/typo3conf/l10n',
'var',
'private/fileadmin',
]);
/*
* Cleanup
*/
set('clear_paths', [
'.git/',
'build/',
'.editorconfig',
'.env.example',
'.gitignore',
'.gitattributes',
'composer.json',
'composer.lock',
'deploy.php',
'hosts.yml',
'*.md',
]);
/*
* Helper
*/
set('copy_dirs', [
'.',
]);
set('writable_dirs', [
'{{typo3_webroot}}/fileadmin',
'{{typo3_webroot}}/typo3temp',
'{{typo3_webroot}}/typo3conf',
'private/fileadmin',
]);
/**
* Custom Tasks
*/
/*
* Local build
*/
task('deploy:build', function () {
set('deploy_path', get('deploy_path_local'));
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');
// invoke('deploy:vendors');
// invoke('deploy:clear_paths');
})->onRoles('build');
/*
* Upload local => external
*/
task('deploy:upload', function () {
upload(
'{{deploy_path_local}}/release/',
'{{release_path}}',
[
'options' => [
'--delete'
]
]
);
});
/*
* Updates
*/
task('deploy:cli_scripts', function () {
run('{{release_path}}/vendor/bin/typo3cms install:fixfolderstructure');
run('{{release_path}}/vendor/bin/typo3cms install:generatepackagestates');
run('{{release_path}}/vendor/bin/typo3cms database:updateschema');
run('{{release_path}}/vendor/bin/typo3cms cache:flush');
});
/**
* Deployment
*/
task('deploy', [
'deploy:info',
// 'deploy:prepare',
// 'deploy:lock',
// 'deploy:release',
'deploy:build',
// 'deploy:copy_dirs',
// 'deploy:upload',
// 'deploy:shared',
// 'deploy:writable',
// 'deploy:cli_scripts',
// 'deploy:symlink',
// 'deploy:unlock',
// 'cleanup',
])->desc('Deploy your project');
after('deploy', 'success');
after('deploy:failed', 'deploy:unlock'); Sadly this doesn't checkout anything from git. |
I try to debug why the branch is empty in my initial case. When deployer/src/Configuration/Configuration.php Lines 55 to 79 in 5f32216
$this->collection is:
And $config = Deployer::get()->config
So the branch isn't inherited from the target host. Would it be possible to read the current target host within this context? deployer/recipe/deploy/update_code.php Line 62 in 5f32216
|
What if you override branch with set function? set('branch', ...); |
At which context/place? |
When I add this override in my deploy.php, I can't read the origin target host: set('branch', function () {
# ----
$host = Context::get()->getHost();
$config = $host->getConfig();
# ----
try {
$branch = runLocally('git rev-parse --abbrev-ref HEAD');
} catch (\Throwable $exception) {
$branch = null;
}
if ($branch === 'HEAD') {
$branch = null; // Travis-CI fix
}
if (input()->hasOption('branch') && !empty(input()->getOption('branch'))) {
$branch = input()->getOption('branch');
}
return $branch;
}); |
I did some puzzling, but sadly without success: <?php
namespace Deployer;
use Deployer\Task\Context;
require_once 'recipe/common.php';
/**
* Setup
*/
inventory('hosts.yml');
// ...
// --- NEW
set('target_host_branch', function () {
$hostConfig = Context::get()->getHost()->getConfig();
return $hostConfig->get('branch');
});
// --- NEW
// ...
/**
* Custom Tasks
*/
// --- NEW
task('config:load_branch', function () {
// Get's the correct branch, but doesn't set it
set('branch', get('target_host_branch'));
});
// ---
/*
* Local build
*/
task('deploy:build', function () {
set('deploy_path', get('deploy_path_local'));
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');
// invoke('deploy:vendors');
// invoke('deploy:clear_paths');
})->local();
// --- NEW
before('deploy:build', 'config:load_branch');
// ---
// ...
/**
* Deployment
*/
task('deploy', [
'deploy:info',
// 'deploy:prepare',
// 'deploy:lock',
// 'deploy:release',
'deploy:build',
// 'deploy:copy_dirs',
// 'deploy:upload',
// 'deploy:shared',
// 'deploy:writable',
// 'deploy:cli_scripts',
// 'deploy:symlink',
// 'deploy:unlock',
// 'cleanup',
])->desc('Deploy your project');
after('deploy', 'success');
after('deploy:failed', 'deploy:unlock'); Withing The |
Why was this issue closed without comment? I still not found a solution to this issue. |
It's should be fixed in master. Now all settings live in configuration and globally/per host overrateable. |
Thanks, I will test it. :) |
Note, what master isn't finished yet. A lot of new and awesome stuff going on right now there. |
Was this issue fixed? Have the exact same problem with deployer 6.8.0. |
@ggolda @antonmedv |
I already fixed it in master. For bookkeeping I’d like to mark it as closed to not popup in search when I’m working on other issues. |
Add `branch` param after issue deployphp#1946 FIXED
Add `branch` param after issue #1946 FIXED
Hi,
I have the following setup with Deployer v6.5.0:
hosts.yml:
deploy.php:
What happens:
If I deploy the staging stage with
vendor/bin/dep deploy staging
it deploys a version on the correct host, but always the master-Branch.It works only, if a explicitly add the
--branch
-option to thedeploy
-command.Result on the command line:
What should happen:
Deployer should respect the branch-setting in the hosts.yml.
What I know so far:
This condition isn't resolved to true in my case:
deployer/recipe/deploy/update_code.php
Lines 61 to 64 in 861f1a3
How to resolve this issue? Do I missed something?
The text was updated successfully, but these errors were encountered: