Sync secrets to GitHub Actions
ProductEnv can write an environment's values to GitHub Actions, as repository secrets or as the secrets of a GitHub deployment environment. It works through the ProductEnv GitHub App, on every plan. You choose when to sync: ProductEnv never overwrites GitHub behind your back.
آخر تحديث
هذه الصفحة متوفرة بالإنجليزية حاليًا.
- In your account settings, open Connected Accounts and connect GitHub.
- Choose Install GitHub App, install it on your GitHub account or organization, and pick the repositories ProductEnv may access.
- Open the project's environment, choose Connectors in the secrets toolbar, then Connect GitHub Repository. Pick the GitHub account, search for the repository and choose Connect.
- Connecting a repository takes the organization owner, who must also be an admin of the repository on GitHub.
- A project connects to one repository. Several apps of the project can share it, which suits a monorepo.
- The app asks GitHub for read and write access to Actions secrets, variables and environments, and read access to metadata. Administration access is optional: it lets the first sync create a missing GitHub environment.
| Setting | Choices |
|---|---|
| Destination | Repository (every workflow of the repository can read it) or GitHub environment (only jobs that use that environment) |
| Format | One .env secret (the default: the whole environment in one secret) or One secret or variable per key |
| Secret name | For the .env format: the default name, such as PRODUCT_ENV_PRODUCTION_SECRETS (PRODUCT_ENV_BACKEND_PRODUCTION_SECRETS for an app named backend), or a name you choose |
| Write as variables | Per-key format: tick keys to write them as plain-text Actions variables instead of secrets |
| Remove values ProductEnv synced before | On by default: deletes names that an earlier ProductEnv sync wrote and that no longer exist |
Each value is encrypted with the destination's public key before it is sent, as GitHub requires. Changing the destination or renaming the .env secret leaves the old values on GitHub, no longer managed.
Choose Sync with GitHub Repository in the secrets toolbar (or Sync now and Sync all when several destinations are set up), then confirm. Syncs are manual; the settings show Last synced with the date and who synced.
Syncing needs the Sync GitHub permission, and the person syncing (or the organization owner) must be an admin of the repository on GitHub. After a sync, Copy workflow example gives a step that reads the values:
# The whole environment as one .env secret (the default format)
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Write .env
run: printf '%s' "$ENV_FILE" > .env
env:
ENV_FILE: ${{ secrets.PRODUCT_ENV_PRODUCTION_SECRETS }}A sync checks everything before writing anything, so it never stops halfway:
- Each value is at most 48 KB.
- At most 100 secrets per repository and per environment, 500 variables per repository and 100 per environment.
- Names use letters, digits and underscores, don't start with a digit, and don't start with
GITHUB_. GitHub compares them without case. - Keys like
ConnectionStrings:Defaultare written asConnectionStrings__Default. In the per-key format, empty values are skipped.
Check drift compares the key names in ProductEnv with those on GitHub (per-key format only).
Disconnect GitHub repository stops syncing to it. Nothing is deleted on GitHub. To remove ProductEnv's access entirely, pause or uninstall the app from Connected Accounts.
Does ProductEnv sync to GitHub automatically when a secret changes?
- No. GitHub syncs run when someone chooses Sync, so a change reaches your workflows only when you decide. Deploy integrations such as Vercel or AWS can sync automatically instead.
Should I use one .env secret or one secret per key?
- One .env secret is simplest: a workflow writes it to a file and every key is there. One secret per key suits workflows that read individual values, and lets you write non-sensitive keys as visible variables.
Can ProductEnv write GitHub organization secrets?
- No. It writes repository secrets and variables, or those of a GitHub deployment environment in the repository.