Skip to content

Commit 02fa9ad

Browse files
committed
🚑 Use firstdeploy:shared after deploy:shared
1 parent e245d26 commit 02fa9ad

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

docs/deploy-task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The following table describes the default deployment tasks in their execution or
99
| `deploy:lock` | Lock the host to ensure we won't try to redeploy before its done. |
1010
| `deploy:release` | Clean up unfinished releases and prepare next release. |
1111
| `deploy:update_code` | Update code by running `git clone` on the new release folder. |
12-
| `firstdeploy:shared` | It will try to copy the shared files directly from the `{{deploy_path}}` if not available on the `{{release_path}}`. This ensures we do not lose shared files or directories that are git-ignored when deploying for the first time on a live server. [Read more here](first-deploy.md). |
1312
| `deploy:shared` | Creating symlinks for shared files and directories. If shared files or directories are not present in the `shared` folder, it will try to resolve then from the `{{release_path}}`. |
13+
| `firstdeploy:shared` | It will try to copy the shared files directly from the `{{deploy_path}}` if not already on the shared folder. This ensures we do not lose shared files or directories that are git-ignored when deploying for the first time on a live server. [Read more here](first-deploy.md). |
1414
| `deploy:vendors` | Installing vendors. Basically running `composer install`. |
1515
| `deploy:writable` | Make directories in `{{writable_dirs}}` writable. |
1616
| `artisan:storage:link` | Execute artisan `storage:link`. |

docs/first-deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Start by deploying using `php artisan deploy`. Unless you have some folders call
1515
>
1616
> If some of your shared files or directories are included in your `.gitignore`, the native `deploy:shared` task will not be able to retrieve them from your repository. This is typically the case for our `.env` file and the `storage` folder. If you already have a `.env` file and a `storage` folder in your live deployment path, you might want to use them in your shared folder.
1717
>
18-
> By default Laravel Deployer provides a `firstdeploy:shared` task (executed right before the `deploy:shared` task) that will copy any shared files and folders present in the `deploy_path` (but absent in the `release_path`) into the shared folder.
18+
> By default Laravel Deployer provides a `firstdeploy:shared` task (executed right after the `deploy:shared` task) that will copy any shared files and folders from the `deploy_path` into the shared folder (if not already in the shared folder).
1919
2020
## 2️⃣ Point root path to current directory
2121
Make sure your server's root path points to the `current` symlink. For example if your `deploy_path` is `var/www/domain.com`, your server configurations should point to `var/www/domain.com/current`.

src/recipe/laravel-deployer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
'deploy:lock',
5151
'deploy:release',
5252
'deploy:update_code',
53-
'firstdeploy:shared',
5453
'deploy:shared',
54+
'firstdeploy:shared',
5555
'deploy:vendors',
5656
'deploy:writable',
5757
'artisan:storage:link',

src/task/firstdeploy.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@
77
$sharedPath = "{{deploy_path}}/shared";
88

99
foreach (get('shared_dirs') as $dir) {
10-
if (
11-
! test("[ -d $sharedPath/$dir ]") &&
12-
! test("[ -d {{release_path}}/$dir ]") &&
13-
test("[ -d {{deploy_path}}/$dir ]")
14-
) {
10+
if (test("[ -d {{deploy_path}}/$dir ]")) {
1511
run("mkdir -p $sharedPath/$dir");
16-
run("cp -rv {{deploy_path}}/$dir $sharedPath/" . dirname(parse($dir)));
12+
run("rsync -r --ignore-existing {{deploy_path}}/$dir $sharedPath/" . dirname(parse($dir)));
1713
}
1814
}
1915

2016
foreach (get('shared_files') as $file) {
21-
if (
22-
! test("[ -f $sharedPath/$file ]") &&
23-
! test("[ -f {{release_path}}/$file ]") &&
24-
test("[ -f {{deploy_path}}/$file ]")
25-
) {
17+
if (test("[ -f {{deploy_path}}/$file ]")) {
2618
run("mkdir -p $sharedPath/" . dirname(parse($file)));
27-
run("cp -rv {{deploy_path}}/$file $sharedPath/$file");
19+
run("rsync -r --ignore-existing {{deploy_path}}/$file $sharedPath/$file");
2820
}
2921
}
3022
});

0 commit comments

Comments
 (0)