diff --git a/README.md b/README.md index 3c1588f..7630be5 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ jobs: | `FORGE_INSTALL_SSL` | `false` | When enabled, a Let's Encrypt SSL will be provisioned for the domain | | `FORGE_DEPLOY_SCRIPT` | | Additional steps to add to your deploy process. Use `;` to delineate between steps (Ex: `npm install; npm run build`) | | `FORGE_ENV_VARS` | | Environment variables to append (or replace if they already exist) | +| `FORGE_INITIAL_ENV_VARS` | | If you store the full .env in a single GitHub Secrets variable assigning that variable here becomes your starting point | | `FORGE_COMPOSER_INSTALL_ON_MOUNT` | `true` | If `composer install` should be ran when the repo is mounted. | | `FORGE_ENABLE_DB` | `false` | Whether your site needs a database. If `true` one will be created for you and shared in the post-deploy comment | | `FORGE_DB_PASSWORD` | | The master password for your `forge` database user. This will be placed into your project's .env automatically | diff --git a/app/Data/Sandbox.php b/app/Data/Sandbox.php index 5c7c739..e502fca 100644 --- a/app/Data/Sandbox.php +++ b/app/Data/Sandbox.php @@ -159,6 +159,18 @@ public function updateDeployScript(): void */ public function updateEnvironmentVars(): void { + // If we have initial environment variables (from GitHub secrets), let's use that as the new starting point + if (config('forge.initial_env_vars')) { + $this->forge->updateSiteEnvironmentFile( + config('forge.server'), + $this->getSite()->id, + config('forge.initial_env_vars') + ); + + // In case Forge is slow to update the environment file, let's wait a few seconds + sleep(5); + } + $envFile = $this->forge->siteEnvironmentFile( config('forge.server'), $this->getSite()->id diff --git a/builds/blacksmith b/builds/blacksmith index a7fe08c..f6241dd 100755 Binary files a/builds/blacksmith and b/builds/blacksmith differ diff --git a/config/forge.php b/config/forge.php index 15ecd26..98a782c 100644 --- a/config/forge.php +++ b/config/forge.php @@ -39,6 +39,9 @@ // Additional deploy commands to run after the default deploy script 'deploy_script' => env('FORGE_DEPLOY_SCRIPT', ''), + // If you have your environment variables set in a GitHub secrets variable this is a convenient way to make the initial .env those values + 'initial_env_vars' => env('FORGE_INITIAL_ENV_VARS'), + // Additional environment variables to set (or replace if they already exist) 'env_vars' => env('FORGE_ENV_VARS'),