Skip to content

update_code recipe - 3rd option update_code_strategy that loads submodule #4063

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions recipe/deploy/update_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
// Can be one of:
// - archive
// - clone (if you need the origin repository `.git` dir in your {{release_path}})
// - clone_submodule (same as `clone`, but running `git submodule init` and `git submodule update` as well)
set('update_code_strategy', 'archive');

// Sets environment variable _GIT_SSH_COMMAND_ for `git clone` command.
Expand Down Expand Up @@ -114,6 +115,13 @@
run("$git clone -l $bare .");
run("$git remote set-url origin $repository", env: $env);
run("$git checkout --force $target");
} elseif (get('update_code_strategy') === 'clone_submodule') {
cd('{{release_path}}');
run("$git clone -l $bare .");
run("$git remote set-url origin $repository", env: $env);
run("$git checkout --force $target");
run("$git submodule init");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to define it as a separate task which can be attached if needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I'm not much into Deployer. I don't know how to solve this differently. Also, a separate task just for basically one line would be more complex.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task('deploy:git:submodules', function () {
    run('git submodule init');
    run('git submodule update');
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host('production')
    ->set('needs_submodules', true);

after('deploy:update_code', function () {
    if (get('needs_submodules', false)) {
        invoke('deploy:git:submodules');
    }
});

run("$git submodule update");
} else {
throw new ConfigurationException(parse("Unknown `update_code_strategy` option: {{update_code_strategy}}."));
}
Expand Down
Loading