Skip to content

Commit

Permalink
Fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Aug 15, 2024
1 parent d2c5137 commit 105e57c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/task/setono_dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* 1. We use the parameter previous_release which is set during the deploy:release step
*
* 2. The deploy:update_code step uses git clone to create the release directory and that command expects an empty dir
* 2. The deploy:update_code step can use git clone to create the release directory and that command expects an empty dir
*/
task('dotenv:prepare', static function (): void {
$stage = getStage();
Expand All @@ -36,6 +36,11 @@
run(sprintf('echo "APP_ENV=%s" > {{release_path}}/.env.local', $stage));
}

// if the .env.[stage].local file exists, we don't need to do anything
if (test(sprintf('[ -f {{release_path}}/.env.%s.local ]', $stage))) {
return;
}

if (has('previous_release') && test(sprintf('[ -f {{previous_release}}/.env.%s.local ]', $stage))) {
run(sprintf('cp {{previous_release}}/.env.%s.local {{release_path}}', $stage));
} else {
Expand Down Expand Up @@ -166,7 +171,7 @@
function getStage(): string
{
$labels = get('labels');
if(!is_array($labels)) {
if (!is_array($labels)) {
return 'prod';
}

Expand Down

0 comments on commit 105e57c

Please sign in to comment.