diff --git a/README.md b/README.md index 9685371..185b1de 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/Data/Sandbox.php b/app/Data/Sandbox.php index 1cb20f9..600e333 100644 --- a/app/Data/Sandbox.php +++ b/app/Data/Sandbox.php @@ -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'), + ); + } } /** diff --git a/builds/blacksmith b/builds/blacksmith index e053356..25a5813 100755 Binary files a/builds/blacksmith and b/builds/blacksmith differ diff --git a/config/forge.php b/config/forge.php index d71ce80..0fbf259 100644 --- a/config/forge.php +++ b/config/forge.php @@ -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', ''), @@ -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'), ];