Skip to content

Commit

Permalink
Allow initial var set
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbushnell committed Jan 13, 2025
1 parent dc2a6f9 commit 2ec575d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
12 changes: 12 additions & 0 deletions app/Data/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified builds/blacksmith
Binary file not shown.
3 changes: 3 additions & 0 deletions config/forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),

Expand Down

0 comments on commit 2ec575d

Please sign in to comment.