Skip to content

Commit e883622

Browse files
xel1045Gandhi11
authored andcommitted
feat: allow dotenv-vars to be configured when deploying
1 parent c885301 commit e883622

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Envoy.blade.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
$deploy = new Exolnet\Envoy\ConfigDeploy(get_defined_vars());
55
$environment = $deploy->getEnvironment();
66
extract($environment->extractVariables());
7+
8+
$dotenvVars = array_filter(explode(PHP_EOL, $dotenvVars ?? ''));
79
@endsetup
810

911
@servers(['web' => $serverString])
@@ -49,6 +51,7 @@
4951
deploy:git
5052
deploy:link
5153
deploy:copy
54+
deploy:dotenv
5255
deploy:composer
5356
deploy:npm
5457
deploy:provisioned
@@ -80,6 +83,7 @@
8083
deploy:git
8184
deploy:link
8285
deploy:copy
86+
deploy:dotenv
8387
deploy:composer
8488
deploy:npm
8589
deploy:provisioned
@@ -254,6 +258,21 @@
254258
@endforeach
255259
@endtask
256260

261+
@task('deploy:dotenv')
262+
cd "{{ $releasePath }}"
263+
264+
@foreach($dotenvVars as $dotenvVar)
265+
@php
266+
[$dotenvVarName, $dotenvVarValue] = explode('=', $dotenvVar, 2);
267+
268+
$dotenvVarName = trim(escapeshellarg(trim($dotenvVarName)), '\'');
269+
$dotenvVarValue = trim(escapeshellarg(trim($dotenvVarValue)), '\'');
270+
@endphp
271+
272+
sed -i -E "s/^(#\\s*)?{{ $dotenvVarName }}=.*/{{ $dotenvVarName }}={{ $dotenvVarValue }}/" .env
273+
@endforeach
274+
@endtask
275+
257276
@task('deploy:composer')
258277
@foreach (array_unique([$releasePath, $assetsPath]) as $path)
259278
cd "{{ $path }}"

0 commit comments

Comments
 (0)