Last active
February 20, 2023 17:25
-
-
Save fgilio/2c863bf12ecae14e534b721a1181dd5c to your computer and use it in GitHub Desktop.
Revisions
-
fgilio revised this gist
Sep 13, 2022 . No changes.There are no files selected for viewing
-
fgilio revised this gist
Sep 13, 2022 . No changes.There are no files selected for viewing
-
fgilio created this gist
Sep 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ stages: - deploy .setup_staging_env_file: &setup_staging_env_file | echo "$STAGING_SECRETS" > staging_secrets.php .setup_production_env_file: &setup_production_env_file | echo "$PRODUCTION_SECRETS" > production_secrets.php staging: script: - *setup_staging_env_file - vapor deploy staging production: script: - *setup_production_env_file - vapor deploy production This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <?php // Store this files as a regular text variable in GitLab CI return [ 'SECRET_1' => 'foo', 'SECRET_2' => 'bar', // This variable contains a double $$ to overcome interpolation in GitLab CI 'SECRET_3' => '7iryufv1gui2hj$$C&F)Jfghsajsb@a(&YFV', ]; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ <?php namespace Laravel\Vapor\Runtime; /** * We're overriding Vapor's original class witht this one using composer. * Make sure it's located in this path: * vendor/laravel/vapor-core/src/Runtime/Secrets.php */ class Secrets { public static function addToEnvironment($path, $parameters, $file) { echo 'Overriden Secrets management'.PHP_EOL; /** * Extract the path to project root. * Vapor will automatically call this method when building * the project, and will provide the path to vaporSecrets.php * which will be located at the root. */ $path = str_replace('vaporSecrets.php', '', $file); if (file_exists($path.'staging_secrets.php')) { $parameters = require $path.'staging_secrets.php'; } if (file_exists($path.'production_secrets.php')) { $parameters = require $path.'production_secrets.php'; } return tap($parameters, function ($variables) { foreach ($variables as $key => $value) { echo "Injecting secret [{$key}] into runtime.".PHP_EOL; $_ENV[$key] = $value; $_SERVER[$key] = $value; } }); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ { "autoload": { "files": [ "vendor-overrides/laravel/vapor-core/src/Runtime/Secrets.php" ], "exclude-from-classmap": [ "vendor/laravel/vapor-core/src/Runtime/Secrets.php" ] } }