Skip to content

Commit

Permalink
Add remote option to update_code_strategy to rename remote to reposit…
Browse files Browse the repository at this point in the history
…ory (#3466)

* Add 'remote' option to 'update_code_strategy'

* Using archive and then add remote to speedup deployment

* Optimize remote option and add documentation

* Optimize code

* Update docs

* Combine clone and remote to remove duplicate code

* Removed  option and merge functionality into  option

* Generate docs

* Generate docs
  • Loading branch information
jhhazelaar authored Feb 10, 2023
1 parent ede6594 commit 3953996
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/recipe/deploy/update_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The value of this configuration is autogenerated on access.
Sets deploy:update_code strategy.
Can be one of:
- archive
- clone (if you need `.git` dir in your [release_path](/docs/recipe/deploy/release.md#release_path))
- clone (if you need the origin repository `.git` dir in your [release_path](/docs/recipe/deploy/release.md#release_path))

```php title="Default value"
'archive'
Expand Down
7 changes: 6 additions & 1 deletion recipe/deploy/update_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// Sets deploy:update_code strategy.
// Can be one of:
// - archive
// - clone (if you need `.git` dir in your {{release_path}})
// - clone (if you need the origin repository `.git` dir in your {{release_path}})
set('update_code_strategy', 'archive');

// Sets environment variable _GIT_SSH_COMMAND_ for `git clone` command.
Expand Down Expand Up @@ -100,12 +100,17 @@

run("$git remote update 2>&1", ['env' => $env]);


// Copy to release_path.
if (get('update_code_strategy') === 'archive') {
run("$git archive $targetWithDir | tar -x -f - -C {{release_path}} 2>&1");
} else if (get('update_code_strategy') === 'clone') {
cd('{{release_path}}');
run("$git clone -l $bare .");
run("$git remote set-url origin $repository", ['env' => $env]);

$target = get('branch', 'HEAD');

This comment has been minimized.

Copy link
@alterphp

alterphp Mar 1, 2023

Suspecting to be the cause of #3519. Why not getting target instead of branch ?

This comment has been minimized.

Copy link
@antonmedv

antonmedv Mar 1, 2023

Member

Yes. Looks like. Will fix.


run("$git checkout --force $target");
} else {
throw new ConfigurationException(parse("Unknown `update_code_strategy` option: {{update_code_strategy}}."));
Expand Down

0 comments on commit 3953996

Please sign in to comment.