Skip to content

Commit

Permalink
Add configurable post-mount commands and composer installation option
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbushnell committed Jan 2, 2025
1 parent 85ba2aa commit 80e13f0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,29 @@ jobs:
## ⚙️ Configuration options
| Environment Name | Default value | Description |
|----------------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------|
| `FORGE_TOKEN` | | The [API token](https://forge.laravel.com/docs/accounts/api) to use to authenticate to your Forge account |
| `FORGE_SERVER` | | The ID of the server to use when provisioning new sites |
| `FORGE_APP_ID` | | The prefix for your domain and database |
| `FORGE_PR_NUMBER` | | The PR number for your sandbox pull request |
| `FORGE_PHP_VERSION` | `php83` | The version of PHP to use |
| `FORGE_DOMAIN` | | The domain to use (Ex: `domain.com`) |
| `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_WEB_DIRECTORY` | `/public` | The public root of the site |
| `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 |
| `FORGE_BACKUP_PROVIDER` | | When set and when your sandbox uses a database it will be backed up to this provider. Accepts `s3` or `spaces` |
| `FORGE_BACKUP_REGION` | | The region for the backup service you are using |
| `FORGE_BACKUP_BUCKET` | | The bucket to use for the backup |
| `FORGE_BACKUP_ACCESS_KEY` | | The access key for connecting to the bucket |
| `FORGE_BACKUP_SECRET_KEY` | | The secret key for connecting to the bucket |
| `FORGE_GITHUB_TOKEN` | | Used to create a post-deploy comment within the pull request |
| `FORGE_REPO` | | The GitHub repo to deploy and mount for the sandbox generation (Ex: `myorg/repo`) |
| `FORGE_BRANCH` | | The branch to use when mounting your repo to the site |
| Environment Name | Default value | Description |
|------------------------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------|
| `FORGE_TOKEN` | | The [API token](https://forge.laravel.com/docs/accounts/api) to use to authenticate to your Forge account |
| `FORGE_SERVER` | | The ID of the server to use when provisioning new sites |
| `FORGE_APP_ID` | | The prefix for your domain and database |
| `FORGE_PR_NUMBER` | | The PR number for your sandbox pull request |
| `FORGE_PHP_VERSION` | `php83` | The version of PHP to use |
| `FORGE_DOMAIN` | | The domain to use (Ex: `domain.com`) |
| `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_ENV_VARS` | | Environment variables to append (or replace if they already exist) |
| `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 |
| `FORGE_BACKUP_PROVIDER` | | When set and when your sandbox uses a database it will be backed up to this provider. Accepts `s3` or `spaces` |
| `FORGE_BACKUP_REGION` | | The region for the backup service you are using |
| `FORGE_BACKUP_BUCKET` | | The bucket to use for the backup |
| `FORGE_BACKUP_ACCESS_KEY` | | The access key for connecting to the bucket |
| `FORGE_BACKUP_SECRET_KEY` | | The secret key for connecting to the bucket |
| `FORGE_GITHUB_TOKEN` | | Used to create a post-deploy comment within the pull request |
| `FORGE_REPO` | | The GitHub repo to deploy and mount for the sandbox generation (Ex: `myorg/repo`) |
| `FORGE_BRANCH` | | The branch to use when mounting your repo to the site |
| `FORGE_POST_MOUNT_COMMANDS` | | Commands to run after the repository is first mounted |

## 🔒 Backups

Expand Down
11 changes: 10 additions & 1 deletion app/Data/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ public function mountRepository(): void
'repository' => config('forge.repo'),
'branch' => config('forge.branch'),
'database' => $this->databaseName,
'composer' => true,
'composer' => config('forge.composer_install_on_mount'),
'migrate' => false,
])->enableQuickDeploy();

// Execute any post-mount commands if they exist
if (config('forge.post_mount_commands')) {
$this->forge->executeSiteCommand(
config('forge.server'),
$this->getSite()->id,
config('forge.post_mount_commands'),
);
}
}

/**
Expand Down
Binary file modified builds/blacksmith
Binary file not shown.
6 changes: 6 additions & 0 deletions config/forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
// The branch to deploy
'branch' => env('FORGE_BRANCH'),

// Additional deploy commands to run after the default deploy script
'composer_install_on_mount' => env('FORGE_COMPOSER_INSTALL_ON_MOUNT', true),

// Additional deploy commands to run after the default deploy script
'deploy_script' => env('FORGE_DEPLOY_SCRIPT', ''),

Expand All @@ -59,4 +62,7 @@

// The token for the GitHub API to post details to the PR
'github_token' => env('FORGE_GITHUB_TOKEN'),

// Post-mount commands to run
'post_mount_commands' => env('FORGE_POST_MOUNT_COMMANDS'),
];

0 comments on commit 80e13f0

Please sign in to comment.