Skip to content

sync secrets

Terminal window
holocron sync secrets --env <environment> [--project-id <id>] [--target production preview] [--dry-run]

Reads a vault environment and fans its keys out to:

  • CI secrets via the secrets capability (e.g. GitHub Actions secrets)
  • Deployment env vars via the deployment capability (e.g. Vercel env vars) when --project-id is provided. Only the keys repo.secrets.deploy names are sent (below)
  • A Worker’s secrets via the workers capability when --worker <script> is given, with the same key filter. The Worker must already be deployed; the values are write-only and never printed

This is the primary way to keep CI and deployment platform secrets in sync with the vault (1Password, Doppler, Infisical, etc.).

Option Default Description
--env (required) Vault environment to read, one value: a layer word or a literal name (provider-specific — e.g. a 1Password Environment, Doppler config name). There is no positional
--project-id — Deployment project id (e.g. Vercel prj_xxx). Required when syncing to the deployment capability
--target production preview Deployment targets to sync to (space-separated). Options: development, preview, production
--worker — A deployed Worker (script name) to set the vault keys that repo.secrets.deploy names on as secrets, e.g. comlink. Needs a workers provider that can set secrets
--dry-run false Print what would be set without writing secrets
Terminal window
# Fill GitHub Actions secrets from the "ci" layer, as repo.secrets.sync says (needs an entry for "ci")
holocron sync secrets --env ci
# Name the destination by hand when there is no entry
holocron sync secrets --env production --github-secret DEPLOY_TOKEN
# Also sync to Vercel's production and preview environments (needs a repo.secrets.deploy entry for "production")
holocron sync secrets --env production --project-id prj_xxx
# Only sync to production (not preview)
holocron sync secrets --env production --project-id prj_xxx --target production
# Set the Comlink relay's signing secret on its Worker (from the `prod` layer: theholocron/holocron - prod)
holocron sync secrets --env prod --cwd apps/comlink --worker comlink
# Dry-run to see what would be synced
holocron sync secrets --env production --dry-run

Naming the environment: a layer, or a literal name

Section titled “Naming the environment: a layer, or a literal name”

sync secrets --env <environment> takes a layer word (local, dev, ci, prod or preview) or a literal Environment name. preview is the layer of an app’s preview deployment (sync <app> --env preview); it has no fallback to prod. A layer word is the Environment of that layer of this repository, <org>/<repo> - <layer>, from the origin remote (holocron sync secrets --env prod --cwd apps/sentinel reads theholocron/holocron - prod). Anything else is a literal name. A name wins as a literal only when it is not exactly a layer word, so an Environment whose whole name is prod cannot be addressed by that name. A remote that cannot be read is a ConfigError that names the environment option as the fix.

The config does the same: an entry in repo.secrets.sync, repo.variables.sync or repo.secrets.deploy, an item of githubApps, the dev block and the vault provider’s options name a layer instead of an environment. Setting both on one entry is a ConfigError, and an explicit environment still works. Entries are matched by the name they derive, so a layer: "prod" entry belongs to sync secrets --env prod.

Declare where an environment’s keys go in repo.secrets.sync, and sync secrets --env <environment> follows it: each entry whose environment (or layer) matches pushes its keys (every key the vault holds when omitted) to its scope (repo, env=<name> or org=<name>), one step per scope. An Environment that holds both organization and repository secrets is then one command:

repo: {
secrets: {
sync: [
{
layer: "ci",
scope: "org=theholocron",
repos: ["theholocron/holocron", "theholocron/.github"],
keys: ["HOLOCRON_AXIOM_TOKEN", "HOLOCRON_READ_TOKEN"],
},
{ layer: "ci", scope: "org=theholocron", repos: ["theholocron/holocron"], keys: ["HOLOCRON_TURBO_TOKEN"] },
{ layer: "ci", keys: ["HOLOCRON_CODECOV_UPLOAD_TOKEN", "HOLOCRON_VERCEL_TOKEN"] },
],
},
},
Terminal window
holocron sync secrets --env ci --dry-run

local and dev are read by this machine and are never synced (#2104). sync secrets --env local and sync secrets --env dev stop with a ConfigError before the config’s providers or the vault are touched, whatever else is given: --dry-run, --github-secret, --github-secret-scope, --project-id and --worker do not change it. The Environment may be given as the layer word, or by its derived name (<org>/<repo> - dev). Only ci and prod can be synced. A repo.secrets.sync or repo.secrets.deploy entry that names layer: "local" or layer: "dev" does not load, so the repository cannot declare what the command refuses.

secrets (GitHub) fails closed too (#2104). A sync whose Environment matches no repo.secrets.sync entry (by environment or layer), with no --github-secret, and no --project-id or --worker, stops with a ConfigError before the vault is read. --dry-run is refused the same way, so a preview cannot look harmless. The error names the Environment and lists the ones that do have an entry. dev and local have no destination, so a sync for them is always refused.

  • --github-secret <KEY> still works: it names the destination on the command line, at repo scope or at the --github-secret-scope given with it. --github-secret-scope alone names a scope but no keys, and is refused.
  • A sync with only --project-id or --worker writes nothing to secrets; it goes through repo.secrets.deploy as above.
  • An Environment declared only in repo.variables.sync still works and pushes only variables.

An organization secret names who can read it

Section titled “An organization secret names who can read it”

An organization secret is never readable by every repository (#2062, spec tech-org-secret-visibility). Most repositories of an organization are public, so GitHub’s private visibility does not narrow anything; the entry lists the repositories that read the secret, by name in the organization. An entry at org=<name> without repos (visibility selected, which may be left out) is a ConfigError when the config loads, as are visibility: "all" and "private", a repository of another organization, and repos on a repo or env= scope. A key may have one reader list: listing it in two entries with different lists is an error.

The sync resolves each name to its id through the GitHub API, then writes the secret with visibility selected and those ids. A name that does not resolve is a failing row naming the repository, and that secret is not written. GitHub replaces who can read a secret on every write, so the run first reads who can read the organization’s secrets (names only) and puts the change in each row, in a dry run too:

secrets (scope=organization,org=theholocron)
… HOLOCRON_ORG_TOKEN (readers all -> selected [.github, holocron])
… HOLOCRON_READ_TOKEN (readers unchanged (selected [.github, holocron]))
… HOLOCRON_TURBO_TOKEN (new, readers selected [holocron])

If the listing cannot be read, the run says so once, names only the new readers and goes on. A repository secret of the same name overrides the organization one and the sync never deletes, so move a name by deleting the old repository copy by hand; doctor secrets finds the copy that is left. Organization variables keep visibility all by default (private is allowed, see below). The HOLOCRON_NOTIFY_* secrets that setup notifications and new channel write are organization secrets too, and take their readers from the notification layout’s readers (visibility selected, #2131) instead of an entry here, so each secret has one writer; without readers those commands refuse to write them.

--github-secret (and --github-secret-scope) describe one route by hand, win over the config for that run, and --github-secret is the only way to sync an Environment that has no entry. doctor secrets reads the same entries to check what should have been pushed.

A deployment receives only the keys it is told to

Section titled “A deployment receives only the keys it is told to”

A deployment (--project-id) and a Worker (--worker) fail closed: no secret goes where it is not needed. Name what each Environment may send in repo.secrets.deploy, in the holocron.config.ts the sync runs with (--cwd apps/sentinel):

repo: {
secrets: {
deploy: [
// a key is sent when it is in `keys` or starts with `prefix`; either or both
{ layer: "prod", prefix: "SENTINEL_", keys: ["HOLOCRON_AXIOM_ORG"] },
],
},
},
  • An entry with neither a non-empty keys nor a prefix is a ConfigError when the config loads. There is no “all keys”.
  • A sync with --project-id or --worker for an Environment that has no entry stops with a ConfigError before it reads the vault.
  • A name outside the filter is never passed to the provider. It is a skipped row (filtered: not in repo.secrets.deploy), and one line names them all, by name only. --dry-run prints the names that would be sent and the ones kept back.
  • doctor secrets has a deploy-<environment> row listing the same names before you sync.

secrets (GitHub) and variables keep their own routes above and are not affected.

Actions variables from a vault environment

Section titled “Actions variables from a vault environment”

GitHub Actions variables (non-secret values such as TURBO_TEAM) can be filled the same way, so there is one place to edit them. The sync lists decide which names become variables, so the same Environment can feed both; a variable is readable in GitHub afterwards, so list only names that are not secrets. Declare it in repo.variables.sync, names only:

repo: {
variables: {
sync: [
{
layer: "ci", // the same Environment as the secrets: <org>/<repo> - ci
scope: "org=theholocron", // "repo" (the default) or "org=<name>"
keys: ["AXIOM_DATASET", "CLOUDFLARE_ACCOUNT_ID", "TURBO_TEAM"],
visibility: "all", // organization only; "all" (the default) or "private"
},
],
},
},
Terminal window
holocron sync secrets --env ci --dry-run

Each key is written through the source provider (syncVariables, or syncOrgVariables for an organization), one call per key, and nothing is deleted. A blank or missing value is skipped, so GitHub keeps what it has until the vault is filled. An environment that only has variable entries pushes nothing to secrets or deployment. Values are never printed.

A name may be given by repo.variables.sync or as a literal in repo.variables.repo or repo.variables.org, not both: that is a config error, as is prune: true together with sync. doctor secrets checks that the names exist.

A key that is blank in the vault (NAME="", a placeholder for a value still to be found) is skipped in every destination, in a dry run too, with a row saying so. Pushing it would overwrite a working secret with nothing, and no provider can read a secret back to undo that. A listed key the vault does not hold is a skipped row as well, not silently ignored. Skipped rows do not fail the run.

GitHub Actions secrets and variables (repository, environment and organization alike) must use only letters, digits and underscores, must not start with a digit, and must not start with GITHUB_. A name that breaks a rule gets a bare 422 from the API, and retrying cannot help. When the secrets or source provider is github, the sync checks each name first and writes a skipped row, invalid name: <reason>, without calling GitHub. The run does not fail on it, and the key still goes to the other destinations (Vercel accepts GITHUB_APP_ID; Sentinel’s App id and key are SENTINEL_GITHUB_APP_ID and SENTINEL_GITHUB_APP_PRIVATE_KEY for that reason, in the organization secrets too; the workflows fall back to the old SENTINEL_APP_ID and SENTINEL_APP_PRIVATE_KEY until those are removed).

If a vault environment holds such a key (Sentinel’s old GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY), keep it out of the GitHub routes with --github-secret or the keys of a repo.secrets.sync entry, which also removes the skipped row.

  1. The vault capability reads all KEY=VALUE pairs from <environmentId>
  2. Each key is set as a CI secret (via the secrets capability) at the scope repo.secrets.sync gives it. With no entry, the sync is refused unless --github-secret names the keys
  3. If --project-id is provided, each key that repo.secrets.deploy allows is also set as a deployment env var for each --target

--worker only adds and updates secrets; it never removes a binding. A Worker also holds secrets that are not in the vault (for Comlink, COMLINK_<SOURCE>_WEBHOOK, which setup notifications sets), so a key deleted from the vault has to be deleted from the Worker separately. Keys are written one at a time and each is reported. If one fails the exit code is 1, and re-running finishes the rest, since every write is idempotent.

  • Vault plugin token (e.g. HOLOCRON_DOPPLER_TOKEN, HOLOCRON_INFISICAL_TOKEN)
  • HOLOCRON_SECRETS_TOKEN / github.secrets for writing GitHub secrets (an org-resource-owner token, needed for org= scope); org= scope uses it first; repo and environment scopes use HOLOCRON_ADMIN_TOKEN / github.admin first, and each falls back to the other
  • Deployment plugin token (e.g. HOLOCRON_VERCEL_TOKEN) if --project-id is used