mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 00:32:25 +01:00
Add an option to deploy only a sub-folder of the repository (#2821)
* add new sub_directory option * update docs * Update docs/recipe/deploy/update_code.md Co-authored-by: Mario Ramundo <ramundomario@gmail.com> Co-authored-by: Mario Ramundo <ramundomario@gmail.com> Co-authored-by: Anton Medvedev <anton@medv.io>
This commit is contained in:
parent
5550911cf6
commit
baece5a6e3
@ -39,6 +39,22 @@ Can be one of:
|
||||
```
|
||||
|
||||
|
||||
### sub_directory
|
||||
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/update_code.php#L31)
|
||||
|
||||
Specifies a sub directory within the repository to deploy.
|
||||
Works only when [`update_code_strategy`](#update_code_strategy) is set to `archive` (default).
|
||||
|
||||
Example:
|
||||
- set value to `src` if you want to deploy the folder that lives at `/src`.
|
||||
- set value to `src/api` if you want to deploy the folder that lives at `/src/api`.
|
||||
|
||||
Note: do not use a leading `/`!
|
||||
|
||||
```php title="Default value"
|
||||
null
|
||||
```
|
||||
|
||||
### git_ssh_command
|
||||
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/update_code.php#L53)
|
||||
|
||||
@ -49,14 +65,14 @@ will not permit connections to hosts with changed host keys.
|
||||
|
||||
```php title="Default value"
|
||||
'ssh -o StrictHostKeyChecking=accept-new'
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Tasks
|
||||
|
||||
### deploy:update_code
|
||||
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/update_code.php#L59)
|
||||
|
||||
|
||||
Updates code.
|
||||
|
||||
|
@ -52,6 +52,18 @@ set('update_code_strategy', 'archive');
|
||||
// will not permit connections to hosts with changed host keys.
|
||||
set('git_ssh_command', 'ssh -o StrictHostKeyChecking=accept-new');
|
||||
|
||||
/**
|
||||
* Specifies a sub directory within the repository to deploy.
|
||||
* Works only when [`update_code_strategy`](#update_code_strategy) is set to `archive` (default).
|
||||
*
|
||||
* Example:
|
||||
* - set value to `src` if you want to deploy the folder that lives at `/src/api`.
|
||||
* - set value to `src/api` if you want to deploy the folder that lives at `/src/api`.
|
||||
*
|
||||
* Note: do not use a leading `/`!
|
||||
*/
|
||||
set('sub_directory', null);
|
||||
|
||||
/**
|
||||
* Update code at {{release_path}} on host.
|
||||
*/
|
||||
@ -60,6 +72,7 @@ task('deploy:update_code', function () {
|
||||
$git = get('bin/git');
|
||||
$repository = get('repository');
|
||||
$target = get('target');
|
||||
$subtarget = get('sub_directory') ? "$target:{{sub_directory}}" : $target;
|
||||
|
||||
$bare = parse('{{deploy_path}}/.dep/repo');
|
||||
$env = [
|
||||
@ -85,7 +98,7 @@ task('deploy:update_code', function () {
|
||||
|
||||
// Copy to release_path.
|
||||
if (get('update_code_strategy') === 'archive') {
|
||||
run("$git archive $target | tar -x -f - -C {{release_path}} 2>&1");
|
||||
run("$git archive $subtarget | tar -x -f - -C {{release_path}} 2>&1");
|
||||
} else if (get('update_code_strategy') === 'clone') {
|
||||
cd('{{release_path}}');
|
||||
run("$git clone -l $bare .");
|
||||
|
Loading…
x
Reference in New Issue
Block a user