Docs
Setup
Create a Preview bundle
Set GHENV_PREVIEW_BUNDLE in the Preview environment. Its version-1 JSON identifies the repository and holds the approved names and values. This example uses placeholders. Enter your approved development values in GitHub’s secret form.
{"version": 1,
"environment": "Preview",
"repository": "OWNER/REPO",
"secrets": {"API_KEY": "development-placeholder"},
"variables": {"API_BASE_URL": "http://127.0.0.1:3000"}
}Keep the bundle within GitHub’s 48 KiB secret limit. Reserve its name for development values at environment, repository, and organization scope, where GitHub can fall back to a same-named secret.
Set access and approvals
A permitted dispatcher who passes Preview’s approval can request any entry the owner placed in the bundle. Protect the handoff workflow, its default branch, and changes to the bundle. Keep production credentials outside this export boundary.
Usage
Select values for one command
ghenv run --repo OWNER/REPO --workflow pr-preview.yml \
--secrets API_KEY --vars API_BASE_URL -- npm run devAdd --timeout 10m before -- if a handoff needs more than the default five minutes. The child receives terminal streams and its exit status is returned by ghenv. The clean environment keeps tool and terminal settings and the selected values.
Save launch policy in TOML
Commit the names and policy in ghenv.toml. Store values in Preview. The explicit workflow selector works with released and current-source clients.
version = 1
repository = "OWNER/REPO"
workflow = "pr-preview.yml"
default_mode = "preview"
secrets = "API_KEY"
variables = "API_BASE_URL"Run without old dotenv overrides
Configure the app to read its process environment and remove any dotenv loader that could override those values. Expo dotenv loading is disabled for clean launches. Treat browser-facing prefixes such as EXPO_PUBLIC_ as public.
Testing
Check the handoff route
Doctor checks GitHub authentication and workflow metadata. The actual run also checks dispatch access, environment approval, and the selected bundle entries.
Verify a source checkout
mise run setup
mise run build
mise run testRepository tests cover bundle scope, the encrypted handoff, a fixture for the GitHub CLI adapter, and child-process behavior.
Architecture
Follow the encrypted handoff
- RequestName the Preview entries
- ApproveGitHub environment rules
- EncryptOne-time key for the artifact
- LaunchInject values into the child
The CLI creates an ephemeral key pair and sends the public key with the requested names. The exporter validates the bundle’s repository and scope, encrypts the selected values, and uploads ciphertext. The client decrypts in memory and attempts artifact cleanup.
Understand the process boundary
The app receives the requested values in its environment and can read or persist them. Use a remote API for credentials local developers must never read. ghenv supervises the child’s process group during interruptions.
Examples
Start a local fixture stack
This launches the existing command with a clean environment and skips the GitHub handoff.
Switch a profile to local mode
Use a project profile to select the launch mode per invocation. Your app can use local fixture settings for this mode.