public static function replaceEnvVariables($yaml): string
    {
        $matches = null;
        preg_match_all('/%\w+%/', $yaml, $matches);
        $originalValues = $matches[0];
        $replaceValues = [];
        foreach ($originalValues as $match) {
            $envVariable = substr($match, 1, -1);
            $envValue = getenv($envVariable);
            if (!$envValue) {
                $envVariable = strtoupper($envVariable);
                $envVariable = 'SCHEMATIC_'.$envVariable;
                $envValue = getenv($envVariable);
                if (!$envValue) {
                    throw new Exception("Schematic environment variable not set: {$envVariable}");
                }
            }
            $replaceValues[] = $envValue;
        }

        return str_replace($originalValues, $replaceValues, $yaml);
    }