diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index cc5c13407..dc16a216a 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -3219,10 +3219,31 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int // filter magic environments $magicEnvironments = $environment->filter(function ($value, $key) { + $regex = '/\$\{(.*?)\}/'; + preg_match_all($regex, $value, $matches); + if (count($matches[1]) > 0) { + foreach ($matches[1] as $match) { + if (str($match)->startsWith('SERVICE_') || str($match)->startsWith('SERVICE_')) { + return $match; + } + } + } $value = str(replaceVariables(str($value))); return str($key)->startsWith('SERVICE_') || str($value)->startsWith('SERVICE_'); }); + foreach ($environment as $key => $value) { + $regex = '/\$\{(.*?)\}/'; + preg_match_all($regex, $value, $matches); + if (count($matches[1]) > 0) { + foreach ($matches[1] as $match) { + if (str($match)->startsWith('SERVICE_') || str($match)->startsWith('SERVICE_')) { + $magicEnvironments->put($match, '$'.$match); + } + } + $magicEnvironments->forget($key); + } + } $normalEnvironments = $environment->diffKeys($magicEnvironments); if ($magicEnvironments->count() > 0) { foreach ($magicEnvironments as $key => $value) {