mehrancodes / laravel-harbor

a cli tool to Quickly create on-demand preview environment for your app on Laravel Forge.
https://www.laravel-harbor.com
MIT License
75 stars 7 forks source link

Override database name w/ FORGE_DB_NAME environment variable #84

Closed shawnhooper closed 7 months ago

shawnhooper commented 7 months ago

Allows the database name to be overridden.

Use Case

I'm spinning up 2 Forge sites for every pull request against my repository's main branch. One site is for the QA and UAT teams to do their testing in (a regular preview site), and the other one is spun up for running Dusk integration tests.

Both of these sites are being provisioned on the same Forge-controlled AWS EC2 instance.

Let's call the branch we're working with acme .

Setup

There's no subdomain set on the preview environment's provisioning. It will use the branch name by default.

On the dusk environment, I've changed the domain in the provisioning script so that it has "-dusk" appended to it:

      SUBDOMAIN_NAME: ${{ format('"{0}-dusk"', github.head_ref) }}

Problem

Both sites end up with "acme" as the MySQL database and usernames.

Solution

Added a new Forge setting called dbName (environment variable FORGE_DB_NAME) that, if present, gets used instead of the username/database name created by formatting the branch name.