sync secrets
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
secretscapability (e.g. GitHub Actions secrets) - Deployment env vars via the
deploymentcapability (e.g. Vercel env vars) when--project-idis provided. Only the keysrepo.secrets.deploynames are sent (below) - A Worker’s secrets via the
workerscapability 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.).
Options
Section titled “Options”| 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 |
Examples
Section titled “Examples”# 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 entryholocron 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 syncedholocron sync secrets --env production --dry-runNaming 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.
One environment, several scopes
Section titled “One environment, several scopes”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"] }, ], },},holocron sync secrets --env ci --dry-runThe local and dev layers are never synced
Section titled “The local and dev layers are never synced”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.
An environment with no entry is refused
Section titled “An environment with no entry is refused”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-scopegiven with it.--github-secret-scopealone names a scope but no keys, and is refused.- A sync with only
--project-idor--workerwrites nothing tosecrets; it goes throughrepo.secrets.deployas above. - An Environment declared only in
repo.variables.syncstill 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
keysnor aprefixis aConfigErrorwhen the config loads. There is no “all keys”. - A sync with
--project-idor--workerfor an Environment that has no entry stops with aConfigErrorbefore 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-runprints the names that would be sent and the ones kept back. doctor secretshas adeploy-<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" }, ], },},holocron sync secrets --env ci --dry-runEach 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.
Blank and missing values
Section titled “Blank and missing values”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.
Names GitHub refuses
Section titled “Names GitHub refuses”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.
- The
vaultcapability reads all KEY=VALUE pairs from<environmentId> - Each key is set as a CI secret (via the
secretscapability) at the scoperepo.secrets.syncgives it. With no entry, the sync is refused unless--github-secretnames the keys - If
--project-idis provided, each key thatrepo.secrets.deployallows is also set as a deployment env var for each--target
Syncing to a Worker
Section titled “Syncing to a Worker”--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.
Authentication
Section titled “Authentication”- Vault plugin token (e.g.
HOLOCRON_DOPPLER_TOKEN,HOLOCRON_INFISICAL_TOKEN) HOLOCRON_SECRETS_TOKEN/github.secretsfor writing GitHub secrets (an org-resource-owner token, needed fororg=scope);org=scope uses it first; repo and environment scopes useHOLOCRON_ADMIN_TOKEN/github.adminfirst, and each falls back to the other- Deployment plugin token (e.g.
HOLOCRON_VERCEL_TOKEN) if--project-idis used