Skip to content

Deploy targets

Copy values from maruhi to Cloudflare Workers, Vercel, Netlify, and GitHub Actions secrets with maruhi sync, through the vendor CLI you already use or the vendor API, locally, from CI, or right after every maruhi push.

Some platforms do not let you put maruhi run -- <command> in front of your application. Cloudflare Workers, Vercel functions, and Netlify builds read their environment variables from the platform’s own store, so the values have to be copied there before a deploy. GitHub Actions is the same story for the few secrets a workflow cannot lease with maruhi ci run: a prebuilt action’s input, a Dependabot secret. maruhi sync does that, driven by a small config file committed in your repository, through one of two drivers: the platform’s CLI, signed in the way you normally use it (exec, the default), or the platform’s API with a token you store in maruhi (http, for CI and for machines without the vendor CLI). Netlify has only the http driver: its CLI takes the value as a command-line argument, which ps can see. GitHub Actions has only the exec driver: its API takes the value sealed with libsodium, and maruhi leaves that to gh. If you would rather not use maruhi sync, the shell recipes at the end of this page do the same with maruhi run.

How maruhi sync works

  • The mapping from a maruhi environment to a deploy target lives in maruhi.sync.json in your repository. It names the preset (vercel, cloudflare-workers, netlify, or github-actions), the driver, the maruhi environment to decrypt, the variables to copy, and the platform-side environment. It contains no secrets, so it is committed like any other config file. It does decide where the plaintext goes, though: a change to a target’s command, cwd, or options changes which program or which account receives the values, so review edits to this file the way you review a CI workflow. apply prints the command and directory, or the API host and the token variable, it is about to use.
  • maruhi sync plan <target> shows what an apply would write or delete, by variable name and version. It does not decrypt the values.
  • maruhi sync apply <target> decrypts the target’s variables in memory and hands each value to the vendor CLI on its standard input, and nowhere else. A value never appears on a command line, in ps, in your shell history, or in a file. The vendor CLI’s own output is not shown unless it fails, and then only with the values filtered out. With the http driver, the values travel in the body of a request to the platform’s API over TLS instead, and the API’s response is treated the same way: discarded on success, shown on failure with values and the token filtered out.
  • The platform stores the plaintext. That is what a deploy target is: its runtime reads the value from its own store, and that store is now one more place that holds the secret.
  • maruhi stays the source of truth, and copying is one way. Nothing is read back from the platform. Instead, maruhi keeps a receipt of what it delivered (variable names and versions, never values) as an encrypted variable in a maruhi environment you choose, and plan compares that receipt with the current versions. A value edited in the platform’s dashboard is not detected and is overwritten by the next apply.
  • The exec driver runs the vendor CLI you already installed and signed in with (wrangler login, vercel login, gh auth login). It never downloads one, and it switches the vendor CLI’s telemetry off for the run. The http driver is not a fallback that fetches a CLI: it is a second way to reach the same target, with maruhi’s own code and a token you create at the platform once. See Without the vendor CLI: the http driver.
  • A target can also be synced right after every maruhi push to its environment, either from the machine that pushed or by a CI workflow that the push triggers, so a Git-integrated platform such as Vercel never deploys with a stale value. It is opt-in per target and never writes a production target from the pushing machine. See Sync on push.

Set up

  1. Create an environment for the receipts. It is a normal maruhi environment that holds nothing but receipts, so do not use it with maruhi run:

    maruhi env create sync-receipts
  2. Add maruhi.sync.json to the repository root. maruhi sync init prints one for a single target (it reads nothing and contacts no server); save its output as maruhi.sync.json, or write the file by hand from the example below:

    maruhi sync init web --preset vercel --env production --receipts sync-receipts \
      --variables DATABASE_URL,STRIPE_SECRET_KEY --option environment=production
    {
      "version": 1,
      "receipts": { "environment": "sync-receipts" },
      "targets": {
        "web": {
          "preset": "vercel",
          "environment": "production",
          "variables": ["DATABASE_URL", "STRIPE_SECRET_KEY"],
          "options": { "environment": "production" }
        },
        "worker": {
          "preset": "cloudflare-workers",
          "environment": "production",
          "variables": "all",
          "exclude": ["NEXT_PUBLIC_SITE_URL"],
          "cwd": "apps/worker",
          "options": { "name": "my-worker" }
        }
      }
    }
  3. See the plan, then apply it. The vendor CLI runs in the directory of the config file (or in the target’s cwd), so it finds the linked Vercel project or the Worker’s configuration file the same way it does when you run it by hand:

    maruhi sync plan web
    maruhi sync apply web --yes

--yes is needed for a production target: a Vercel target whose environment is production, a Cloudflare Workers target without a named wrangler environment, a Netlify target whose context is production or all, or a GitHub Actions target that writes repository secrets or the secrets of an Environment named production. For other targets, apply runs without it. You can set "production": true or false on a target to override that default.

The plan lists one line per variable: + new to the target, ~ changed since the last delivery (with both versions), = unchanged, - no longer synced (removed from the list, excluded, or deleted in maruhi; apply deletes it at the target), and ! cannot be synced by this preset — a name the platform would not keep as is, an empty value, or a value above the preset’s size limit; each line says which, and apply sends nothing until every ! is resolved. Rules that need the plaintext (such as a trailing newline the vendor CLI would strip) are checked when apply decrypts the values, before anything is sent. The plan’s first line names the destination the preset writes to — for example the repository and Environment of a github-actions target, or the deploy context of a netlify target — and the driver.

The config file

Key Meaning
version Always 1.
project Optional, unless a target has onPush. The project ID this config belongs to; maruhi sync uses it instead of defaultProject, and refuses a --project flag that names a different project.
receipts.environment The maruhi environment that stores the receipts (one variable per target, named sync-receipt:<target>). It must not be one of the synced environments.
targets.<name> One deploy target. The name is yours (letters, digits, _, -) and is the argument to plan, apply, and ci sync.

Each target:

Key Meaning
preset vercel, cloudflare-workers, netlify, or github-actions.
driver Optional. exec (the default when the preset has one): the installed vendor CLI. http: the vendor API with a token stored in maruhi (see below). netlify has only http and github-actions has only exec, so the key can be left out for them.
environment The maruhi environment to decrypt.
variables The names to copy, or "all" for every variable of the environment. A listed name that does not exist stops the command before anything is sent.
exclude Only with "all": names not to copy. Public configuration and platform-owned resources (D1, KV, and R2 bindings on Cloudflare; Vercel Postgres and Blob) belong here or outside maruhi altogether.
production Optional. Whether apply needs --yes. Defaults as described above.
cwd exec only, optional. Where to run the vendor CLI, relative to the config file. Default: the config file’s directory.
command exec only, optional. The vendor CLI to run, relative to cwd. Default: vercel, wrangler, or gh on PATH. Use it when wrangler is a project dependency rather than a global install (for example node_modules/.bin/wrangler).
token http only, required. { "environment": "<maruhi environment ID>", "name": "<variable name>" }: where the platform’s token is stored in maruhi. The token itself is never copied to the target, even when it lives in the synced environment.
options Preset-specific and driver-specific, below.
onPush Optional. apply: sync the target from the pushing machine right after every maruhi push to its environment. workflow: trigger the repository’s workflow with gh instead, so CI syncs it. Needs the top-level project. See Sync on push.
workflow With onPush: "workflow", required. { "file": "maruhi-sync.yml" }, plus optional ref (the branch or tag whose workflow file runs; default: the repository’s default branch) and command (the gh executable; default: gh on PATH).

Vercel options with exec: environment (required: production, preview, or development), gitBranch (a preview branch), project and scope (when the directory is not linked, or to be explicit), and sensitive (false passes --no-sensitive). With http: environment (required), gitBranch, projectId (required: the project ID prj_… or the project name), teamId (the team that owns the project, when the token is a team token), and sensitive.

Cloudflare Workers options with exec: name (the Worker; otherwise wrangler reads it from its configuration file), environment (a named wrangler environment, passed as --env), and config (the path of the wrangler configuration file). With http: accountId (required), name (required: there is no wrangler configuration file to read it from), and environment (a named wrangler environment; the Worker is then <name>-<environment>, which is how wrangler names it).

Netlify options (http only): accountId (required: the team’s slug, the <team> in app.netlify.com/teams/<team>, or its ID), siteId (required: the site’s ID, shown as the project ID in the project’s configuration and stored by netlify link in .netlify/state.json; without it the API would write team-wide shared variables), context (required: the deploy context the value is for, one of production, deploy-preview, branch-deploy, branch, dev, dev-server, or all), branch (with context: "branch", required: the branch name), and secret (whether the variable is marked as secret at Netlify; see Netlify for the default).

GitHub Actions options (exec only): repo (the repository as OWNER/REPO, passed as --repo; without it gh uses the git remote of the directory it runs in, and stops if that directory has several remotes), environment (a GitHub Environment name, passed as --env; without it the target writes repository secrets), and app (actions, the default, dependabot, codespaces, or agents, passed as --app; only actions has Environment secrets). See GitHub Actions secrets.

The config format is version: 1 for every release of maruhi sync: a file from the first release still parses, and every key added since is optional. An older CLI rejects a file that uses the newer keys as “unknown keys”, so upgrade the CLI rather than editing the file.

Required variables: if a variable in the target’s selection is declared as required but has no value yet, plan and apply stop before anything is sent, the same way maruhi run does. If a required variable is not part of the target, plan warns.

Cloudflare Workers

maruhi sync runs wrangler secret bulk, which reads a JSON object from standard input and stores every entry in one request, up to 100 per call. Larger sets are split into several calls. A variable that is no longer synced is deleted in the same call (a null entry). Secrets that already exist under the same names are overwritten. The run sets WRANGLER_SEND_METRICS=false.

Vercel

maruhi sync runs vercel env add <name> <environment> --force --non-interactive once per variable, with the value on standard input, and vercel env rm for a variable that is no longer synced. --force makes an existing variable an update rather than an error. --non-interactive turns any prompt into a failure rather than a hang. The run sets VERCEL_TELEMETRY_DISABLED=1.

  • Values for production and preview are stored as sensitive by default: Vercel does not show them again, in the dashboard or in vercel env ls. Set "sensitive": false in the target’s options to opt out (a team policy may forbid it). Development does not accept sensitive values.
  • The Vercel CLI reads standard input only once. Because the amount that arrives in one read depends on the operating system’s pipe buffer, maruhi sync refuses values above 16 KiB for this preset rather than risk a value cut off silently. Keep very large values out of this target, or set them through the dashboard.
  • The Vercel CLI treats an empty standard input as no value, and strips one trailing newline from a single-line value. maruhi sync refuses an empty value and a single-line value that ends with a newline, and names the variable; push such a value without the trailing newline (printf %s instead of echo).

Netlify

maruhi sync does not run the Netlify CLI (netlify env:set takes the value as a command-line argument). The netlify preset uses the Netlify API through the http driver below, and that is its only driver. What it writes:

  • A Netlify environment variable is one key with one value per deploy context. A target writes the value for the context in its options (production, deploy-preview, branch-deploy, a single branch, dev, dev-server, or all) and leaves the other contexts’ values alone. A value set for a specific context takes precedence at Netlify over a value set for all contexts, so a target with "context": "production" overrides an existing “same value for all contexts” entry for production deploys only.
  • Variables are marked as secret by default ("secret": true): Netlify then never shows the value again in its dashboard, CLI, or API, and scans build output for it. Netlify does not accept secret values for the all, dev, and dev-server contexts, so the default is false there, and "secret": true is a config error for them. Set "secret": false to opt out for the other contexts. The flag is applied when maruhi creates the variable; a variable that already exists keeps its flag and scopes, because the API call that sets one context’s value does not change them. So when a variable already exists at Netlify as not secret and the target asks for a secret value, apply stops at that variable without sending it and says so: mark it as secret in the dashboard, delete it there and apply again, or set "secret": false for the target.
  • Scopes are left to Netlify’s default (every scope) when the variable is created, except that a secret variable gets the builds, functions, and runtime scopes, the same three the Netlify CLI uses, because Netlify does not allow secrets in the post processing scope. Choosing scopes yourself is a Pro plan feature and is done in the dashboard.
  • A variable that is no longer synced loses its value for the target’s context only, found by ID in the site’s variable list. When that was the variable’s last value, the variable is deleted as a whole so that no empty variable is left behind. A variable whose only value is for all contexts is not touched by a target with a specific context.

GitHub Actions secrets

A GitHub Actions job normally needs no GitHub secret at all: maruhi ci run and maruhi ci sync lease the values with the job’s OIDC token (see GitHub Actions). What is left are the secrets a workflow reads through ${{ secrets.NAME }} before any command of yours runs: the input of a prebuilt action, a Dependabot secret, a reusable workflow’s secrets: inherit. The github-actions preset copies those from maruhi, so that they too have one source of truth. Where a prebuilt action is a thin wrapper around a vendor CLI, prefer running that CLI under maruhi ci run and drop the secret instead.

maruhi sync runs gh secret set <name> once per variable, with the value on standard input, and gh secret delete <name> for a variable that is no longer synced. gh seals the value to the repository’s public key on your machine before it leaves; that is why the preset has no http driver: the sealing needs libsodium, which maruhi does not implement. The run sets GH_TELEMETRY=false and DO_NOT_TRACK=1. It uses the gh you installed and signed in with (gh auth login, or a GH_TOKEN in the environment); the token needs write access to the repository’s secrets.

{
  "version": 1,
  "receipts": { "environment": "sync-receipts" },
  "targets": {
    "dependabot": {
      "preset": "github-actions",
      "environment": "ci",
      "variables": ["NPM_TOKEN"],
      "options": { "repo": "acme/app", "app": "dependabot" }
    }
  }
}

maruhi sync init dependabot --preset github-actions --env ci --receipts sync-receipts --variables NPM_TOKEN --option repo=acme/app --option app=dependabot prints this target.

  • Repository secrets are written when the target has no environment; with one, the secrets of that GitHub Environment (Actions only). gh secret set looks the Environment’s public key up first and does not create the Environment, so create it in the repository settings before the first apply. app selects Dependabot or Codespaces secrets instead of Actions secrets.
  • gh strips every trailing newline from the value it reads (a PEM key pushed from a file usually ends with one), for a single-line and a multi-line value alike. Rather than deliver something else than what maruhi holds, apply refuses a value that ends with a newline and names the variable; push it without the newline (printf %s instead of echo). An empty value is handed to gh unchanged.
  • GitHub stores secret names in uppercase and treats Foo and FOO as the same secret, which is how one maruhi variable could overwrite or delete another at the target. The preset therefore accepts only names that GitHub keeps unchanged: uppercase letters, digits, and _, not starting with a digit or with GITHUB_. plan marks any other name with !, and apply refuses to send anything until it is renamed in maruhi.
  • GitHub limits a secret to 48 KB and a repository or Environment to 100 secrets. maruhi sync does not check these itself: gh reports the API’s refusal and apply stops at that variable, with the ones before it recorded in the receipt.
  • A variable that is no longer synced is deleted by name (gh secret delete), no list is read. A name that was already removed at GitHub makes that delete fail, and apply says how to reset the receipt.
  • Organization and user secrets (--org, --user) are not covered by the preset; use gh directly for them.

Without the vendor CLI: the http driver

In CI, or on a machine where you do not want the vendor CLI, set "driver": "http" on a target (for netlify it is implied; github-actions has no http driver, see above). maruhi sync then talks to the platform’s API itself, with a token that you create once at the platform and store in maruhi as a normal variable. The host is fixed by the preset (api.cloudflare.com, api.vercel.com, api.netlify.com) and cannot be changed in the config. plan never contacts the platform; only apply and ci sync do, and only for the target you name.

  1. Create the token at the platform with the least permission the target needs:

    • Cloudflare Workers: an API token scoped to the account with the permission Workers Scripts: Edit (dashboard: My Profile, API Tokens, Create Token; pick a custom token and add that one permission for the account). The Worker must already exist: unlike wrangler, the http driver does not create a draft Worker.
    • Vercel: an access token from Account Settings, Tokens. Scope it to the team that owns the project, and set teamId in the target’s options when the project belongs to a team.
    • Netlify: a personal access token from User settings, Applications, Personal access tokens (New access token, with an expiration). Netlify has no narrower scope for a token than the user’s own access, so create it from an account that is a member of just that team, and set siteId in the target’s options so that only that site is written.
  2. Store the token in maruhi. Any environment works, and a dedicated one keeps it out of maruhi run (push it without a trailing newline: printf %s, not echo):

    maruhi env create tokens
    printf %s "$CLOUDFLARE_API_TOKEN" | maruhi push CLOUDFLARE_API_TOKEN --env tokens
  3. Point the target at it:

    {
      "version": 1,
      "receipts": { "environment": "sync-receipts" },
      "targets": {
        "worker": {
          "preset": "cloudflare-workers",
          "driver": "http",
          "environment": "production",
          "variables": "all",
          "exclude": ["NEXT_PUBLIC_SITE_URL"],
          "token": { "environment": "tokens", "name": "CLOUDFLARE_API_TOKEN" },
          "options": { "accountId": "0123456789abcdef0123456789abcdef", "name": "my-worker" }
        },
        "web": {
          "preset": "vercel",
          "driver": "http",
          "environment": "production",
          "variables": ["DATABASE_URL", "STRIPE_SECRET_KEY"],
          "token": { "environment": "tokens", "name": "VERCEL_TOKEN" },
          "options": { "environment": "production", "projectId": "prj_abc123", "teamId": "team_xyz" }
        },
        "site": {
          "preset": "netlify",
          "environment": "production",
          "variables": ["DATABASE_URL", "STRIPE_SECRET_KEY"],
          "token": { "environment": "tokens", "name": "NETLIFY_TOKEN" },
          "options": {
            "accountId": "my-team",
            "siteId": "0f1e2d3c-4b5a-6978-8a9b-0c1d2e3f4a5b",
            "context": "production"
          }
        }
      }
    }

    maruhi sync init site --preset netlify --env production --receipts sync-receipts --token-env tokens --token-name NETLIFY_TOKEN --option accountId=my-team --option siteId=… --option context=production prints the site target.

plan, apply, and the receipts work exactly as with the exec driver, and you can switch a target between the two drivers without losing its receipt. Changing a target’s preset is different: the receipt names the preset that wrote it, and plan and apply refuse a receipt written by another preset, because its deliveries describe another platform. The error lists the variables that were delivered there — the receipt is the only record of them, and maruhi never writes to or deletes from a platform the config no longer names — so remove them at the old platform yourself, then reset the receipt as described under Receipts. What differs between the drivers:

  • Cloudflare Workers: one PATCH …/secrets-bulk request per 100 variables, the same request wrangler makes. A variable that is no longer synced is deleted in the same request.
  • Vercel: one request per 25 variables with upsert=true, so an existing variable is updated in place. A variable that is no longer synced is looked up by name in the project’s list for the target environment and branch, then deleted by ID; if the complete list does not contain it, it is treated as deleted. If the list comes back paginated, the variable is not assumed gone: it stays in the receipt and apply reports it, so remove it in the dashboard or apply again. Values in the list are never read. The 16 KiB limit of the exec driver does not apply (it came from the CLI’s stdin handling); Vercel’s own limit is 64 KB across all variables of a deployment.
  • Netlify: the API has no upsert, so apply first lists the site’s variables (names only; values in the list are never read), then sends one request per variable: POST …/env to create a variable that is not there yet, with the target’s context, the secret flag, and the scopes described under Netlify, or PATCH …/env/<name> to set the target’s context on one that exists, which is how the Netlify CLI itself does it. Variables written before a failure stay in the receipt. A variable created by someone else between the list and the request makes the create fail; apply then lists the site again and, since the name is there now, updates it instead. A variable that is no longer synced is looked up in the same list and its value for the target’s context is deleted by ID (or the whole variable, when that was its last value); a name that is not in the list is treated as deleted. Netlify accepts values up to 5,000 characters; a longer one is refused by the API and reported. Netlify’s rate limit of 500 requests per minute is far above what a target needs, and a 429 is retried as below.
  • Retries: a 429 or a 502, 503, or 504 answer is retried up to three times, honoring Retry-After up to 30 seconds. Writes to Cloudflare Workers and Vercel are idempotent, so a retry is safe. On Netlify, creating a variable is not: a create whose response was lost is re-sent and refused as a duplicate, so apply then lists the site again and updates the variable instead, in the same run.
  • Proxies: the CLI honors HTTPS_PROXY and NO_PROXY for these requests.
  • Errors: the API’s response is shown only on failure, with the values and the token filtered out. A missing Worker (10007) tells you to deploy it first. A Netlify 404 on the list usually means a wrong accountId or siteId, or a token from an account that is not a member of the team.

The token variable is never part of what is copied: if it lives in the synced environment, it is excluded automatically, and listing it in variables is a config error.

Sync on push

A value changes only when someone runs maruhi push, so the moment a deploy target goes stale is always a moment when the writer’s CLI is running. Set onPush on a target and maruhi push syncs it as soon as the push is accepted, in one of two ways:

  • "onPush": "apply": the pushing machine runs the same steps as maruhi sync apply for that target, right after the Pushed line. Because the receipt records what was delivered before, only the variable you just pushed is written (plus anything an earlier sync left pending), and the receipt is advanced. This needs the vendor CLI (or, with the http driver, the token in maruhi) on every machine that pushes. It is refused for a production target: production is written only by a maruhi sync apply --yes that someone runs on purpose.
  • "onPush": "workflow": the pushing machine runs gh workflow run <file> -f target=<name> in the config file’s directory, with your own GitHub sign-in, and a CI job does the sync with maruhi ci sync. The writer never holds the platform’s token, and a production target can be synced this way too, because the decision to write production is the --yes in the workflow file, reviewed in the repository, and a GitHub Environment with required reviewers can hold the run until someone approves it. The command line carries the workflow name and the target name, never a value or a variable name; CI reads the values from maruhi. maruhi push reports that the run was accepted and does not wait for it.
{
  "version": 1,
  "project": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "receipts": { "environment": "sync-receipts" },
  "targets": {
    "preview": {
      "preset": "vercel",
      "environment": "staging",
      "variables": ["DATABASE_URL", "STRIPE_SECRET_KEY"],
      "options": { "environment": "preview" },
      "onPush": "apply"
    },
    "web": {
      "preset": "vercel",
      "environment": "production",
      "variables": ["DATABASE_URL", "STRIPE_SECRET_KEY"],
      "options": { "environment": "production" },
      "onPush": "workflow",
      "workflow": { "file": "maruhi-sync.yml" }
    }
  }
}

maruhi sync init writes these keys with --on-push apply or --on-push workflow --workflow maruhi-sync.yml (together with --project).

How maruhi push finds the config: it reads --config <file> when you pass it, and otherwise maruhi.sync.json in the working directory when that file exists. A config with onPush must name its project, and the default file is used only when that project is the one you are pushing to; otherwise the push goes through and a note says the config was left alone. A --config you passed explicitly must match, or the command stops before pushing. Only targets whose environment is the environment you pushed to, and whose selection includes the variable you pushed, are synced. Remember that this file is executable configuration: it names the program that receives the values. A config that maruhi push found on its own in the working directory therefore never starts a program the file names (a target with command, or a workflow.command), only the preset’s own CLI from PATH; such a target is skipped with a note, and syncs after a push only when you pass --config yourself.

What happens when the sync part fails: the push is already done and its exit code stays 0. The failure is a warning, the receipt is not advanced, so the next maruhi sync plan <target> shows the variable as pending, and either maruhi sync apply <target> or the next CI run delivers it. This covers a vendor CLI that is not installed, a network error, a value the preset cannot carry, and gh that is missing, not signed in, or cannot find the workflow. The one exception is evidence of tampering in the receipts environment, which fails the command the same way it would fail maruhi sync apply.

Pushing several values in a row? Add --no-sync to each push (the default config is not read; it cannot be combined with --config) and run maruhi sync apply <target> once at the end. A push to an environment no target syncs from, or of a variable no target carries, syncs nothing; with the default config it also says nothing, and with an explicit --config a note says that no target matched.

For onPush: "workflow", the workflow file must have a workflow_dispatch trigger with a target input and run maruhi ci sync for it, as in In CI:

on:
  workflow_dispatch:
    inputs:
      target:
        required: true
        type: string

gh dispatches the workflow file on the repository’s default branch unless the target’s workflow.ref says otherwise, and it does not need your local branch to be pushed: the value is already in maruhi, and CI reads it from there. The complete workflow, with a schedule and a GitHub Environment for production, is on GitHub Actions.

Receipts

A receipt records, per target, the version of each variable that was delivered. It is written as a new version of the sync-receipt:<target> variable in the receipts environment after every apply that changed something, encrypted and signed like any other variable, so anyone on the project sees the same delivery state. An apply that fails midway still records what was delivered before the failure, with either driver — the platform refused a request, the vendor CLI failed on one variable or could not be started at all — so the next apply resumes with what is left instead of rewriting everything. Two consequences:

  • maruhi env rotate re-encrypts every value as a new version, with the same plaintext. Pass the config to the rotation (maruhi env rotate production --reason "quarterly" --config maruhi.sync.json) and it advances the receipts of every target synced from that environment, so the next plan still shows those variables as unchanged. Only the rotation itself can do that, because it is the one that knows the plaintext did not change: a variable moves to its re-encrypted version only when this rotation wrote that version and the receipt pointed at the version just before it. A variable the receipt was already behind on, one rewritten by someone else’s concurrent push, and one the rotation could not finish stay as they were, and plan keeps showing them as pending. Advancing a receipt writes nothing to the platform, so it needs no --yes. Without --config, and after the rotations run by maruhi server revoke and maruhi member remove, the receipts are left alone: plan then shows every variable as changed and the next apply rewrites them with the same plaintext, which is harmless.
  • CI does not write receipts (see below), so a maruhi sync apply run locally after a ci sync, including one that maruhi push triggered through onPush: "workflow", still shows what CI already delivered as pending, and rewrites it once.
  • A variable can hold at most 1,000 versions. plan warns when a receipt is close to that limit; deleting the receipt variable (maruhi var rm sync-receipt:<target> --env sync-receipts) starts a fresh one, and the next apply rewrites the target once.
  • Deleting a receipt only forgets what was delivered — it removes nothing at the platform. That is what you want when the receipt is stale for the same destination (the next apply rewrites it). After changing a target’s preset, though, the old platform still holds everything the receipt listed, and maruhi no longer has a record of it; the error that refuses the receipt names those variables, so remove them at the old platform before you delete it.

In CI

In GitHub Actions, maruhi ci sync <target> copies a target on every run of a deploy job. Like maruhi ci run, it needs no sign-in: its own flags name the server, the project, and the committed repository anchor, and it uses an OIDC lease instead of a token. The target comes from the same maruhi.sync.json, so the mapping is reviewed once, in the repository:

maruhi ci sync worker --yes \
  --server https://my.maruhi.app \
  --project 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef \
  --anchor .maruhi/anchor.json
  • The job’s identity must be granted a lease for the target’s environment, and for the token’s environment when the target uses the http driver with a token stored elsewhere (maruhi server grant --lease-policy). Both leases use the same OIDC token and the same ephemeral key.
  • Either driver works. The http driver needs nothing installed on the runner; the exec driver needs the vendor CLI installed and authenticated on the runner, and in that case the deploy job is often already doing the same with maruhi ci run -- wrangler deploy.
  • CI keeps no receipt. A CI job holds no signing key, so it cannot write one. ci sync therefore writes every selected variable on every run (an idempotent update), and it never deletes anything at the target: removing a variable from the target is done locally with maruhi sync apply, which has the receipt.
  • A production target needs --yes here too, so the decision to write production is visible in the workflow file. For a second pair of eyes on production, put the job in a GitHub Environment with required reviewers and name that Environment in the lease policy; see Four eyes on production.
  • The values leave the runner only in the request to the platform (http) or on the vendor CLI’s standard input (exec), and never appear in the job log.

The same job can be started by the writer’s maruhi push through onPush: "workflow" (see Sync on push): give the workflow a workflow_dispatch trigger with a target input and pass it to maruhi ci sync. GitHub Actions has the complete workflows for the two common shapes (re-apply on every deploy, and a dispatched plus scheduled re-apply for Git-integrated platforms), the lease policy that goes with them, and the GitHub Environment setup for production. maruhi ci run still covers the shell recipes below unchanged.

Without maruhi sync: shell recipes

The recipes below do the same copy with maruhi run and the vendor CLI, without a config file or receipts. They are for platforms where you prefer to see every step, or for scripts that already exist.

  • maruhi run decrypts the environment in memory and hands the values to a child process as environment variables. The child reads each value from its environment (printenv, or jq through $ENV) and writes it to the vendor CLI’s standard input.
  • A value never appears on a command line. It is not visible in ps or in your shell history, and set -x does not echo it. Nothing is written to disk: no .env file, no temporary file.
  • After you change a value with maruhi push, run the recipe again. Nothing is read back from the platform, and a value edited in the platform’s dashboard is overwritten by the next copy.
  • List the names in the environment with maruhi pull. It prints names, versions, and sizes, not values. Declare the variables you copy as required (maruhi schema set NAME --required) so that maruhi run stops before anything is copied when one of them has no value.
  • The recipes are written for POSIX sh (bash, zsh, and dash run them unchanged). Windows is not covered.

Cloudflare Workers

wrangler secret bulk reads a JSON object from standard input and stores every entry in one request. jq builds that object from the environment, reading each value through $ENV so that the values stay off the command line. Run it in the Worker’s directory (wrangler takes the Worker name from its configuration file), or pass --name.

maruhi run --env production -- jq -n --args '
  $ARGS.positional
  | map({ key: ., value: ($ENV[.] // error("\(.) has no value")) })
  | from_entries
' DATABASE_URL STRIPE_SECRET_KEY \
  | wrangler secret bulk

Replace DATABASE_URL STRIPE_SECRET_KEY with the names you want to copy. Only jq runs under maruhi run; wrangler runs outside it and sees nothing but the JSON on its standard input.

  • Secrets that already exist under the same names are overwritten. One command handles up to 100 secrets.
  • If a name has no value, jq stops with an error and sends nothing, and wrangler reports that it received no input. Nothing is deleted: in this JSON format a key is deleted only when its value is null, and the filter above never produces one. The exit status of the pipeline is wrangler’s, so in a script under bash or zsh add set -o pipefail to surface the jq error.
  • Named wrangler environments: maruhi run --env staging -- jq … | wrangler secret bulk --env staging. maruhi’s --env chooses the maruhi environment to decrypt; wrangler’s --env chooses the wrangler environment to write to.
  • If wrangler is a dependency of the project rather than a global install, invoke the installed copy the way you usually do (for example npx wrangler secret bulk).

Vercel

vercel env add reads the value from standard input when standard input is not a terminal. Each variable is one call, so the recipe loops over the names inside sh, under a single maruhi run. It first checks that every name has a value, then copies them. Run it in the linked project directory (vercel link), or pass --project.

maruhi run --env production -- sh -c '
  for name in "$@"; do
    printenv "$name" > /dev/null || { echo "$name has no value" >&2; exit 1; }
  done
  for name in "$@"; do
    printenv "$name" | vercel env add "$name" production --force || exit 1
  done
' sh DATABASE_URL STRIPE_SECRET_KEY

Replace DATABASE_URL STRIPE_SECRET_KEY with the names you want to copy; the sh before them is the script’s $0. production is the Vercel environment (production, preview, development, or a comma-separated list); maruhi’s --env chooses the maruhi environment to decrypt.

  • --force overwrites a variable that already exists for the same environment. Without it, the Vercel CLI refuses to add a name that is already there.
  • Values for production and preview are stored as sensitive by default: Vercel does not show them again, in the dashboard or in vercel env ls. Pass --no-sensitive to opt out (a team policy may forbid it). Development does not accept sensitive values.
  • printenv ends the value with a newline, and the Vercel CLI strips one trailing newline from a single-line value. A multi-line value (a PEM key, for example) keeps it.
  • The Vercel CLI reads standard input only once. In a measurement of its reader (CLI 59.11.7, on Linux), a value larger than 64 KiB arrived cut off at 64 KiB with no error; the threshold depends on the system’s pipe buffer, and a sensitive value cannot be inspected afterwards. Keep very large values out of this recipe.
  • Do not use --value: it puts the value on the command line.

GitHub Actions secrets

gh secret set reads the value from standard input when it cannot prompt, and seals it to the repository’s public key before sending it. Each secret is one call, so the recipe has the same shape as the Vercel one: it checks that every name has a value, then copies them. Run it in a clone of the repository (gh takes the repository from the git remote), or pass --repo OWNER/REPO.

maruhi run --env production -- sh -c '
  for name in "$@"; do
    printenv "$name" > /dev/null || { echo "$name has no value" >&2; exit 1; }
  done
  for name in "$@"; do
    printenv "$name" | gh secret set "$name" || exit 1
  done
' sh NPM_TOKEN CODECOV_TOKEN

Replace NPM_TOKEN CODECOV_TOKEN with the names you want to copy; the sh before them is the script’s $0. maruhi’s --env chooses the maruhi environment to decrypt; add --env <name> after gh secret set "$name" to write the secrets of a GitHub Environment instead of repository secrets, and --app dependabot (or codespaces) for another app’s secrets.

  • An existing secret with the same name is overwritten.
  • printenv ends the value with a newline, and gh strips every trailing newline from what it reads, from a multi-line value too. A PEM key pushed with its final newline therefore arrives without it.
  • Names arrive in uppercase: GitHub stores Foo as FOO and treats the two as one secret. Keep the names in maruhi uppercase and distinct.
  • Do not use --body: it puts the value on the command line. Do not use --env-file -: it takes a dotenv-formatted stream, whose parsing changes values that contain #, quotes, or \n.
  • The token gh signs in with (gh auth login, or GH_TOKEN) needs write access to the repository’s secrets; in a fine-grained personal access token that is the Secrets repository permission (read and write) for repository secrets, Environments for Environment secrets, and Dependabot secrets for --app dependabot.

Other platforms

The same shape works for any platform whose CLI reads the value from standard input. The Netlify CLI takes the value as a command-line argument, so there is no recipe for it; use the netlify preset with maruhi sync instead, which talks to the Netlify API.

Vendor CLI telemetry

maruhi sends nothing about you anywhere. Besides your maruhi server, the CLI talks only to peers you named, for your own purpose: on this page, the platform of a target you apply or ci sync with the http driver, which receives your own values and nothing else (the request carries a maruhi-cli/<version> user agent so that the platform can attribute traffic, and no other identifier). Elsewhere the same rule covers, for example, the services the maruhi var rotate and maruhi proxy connectors manage credentials for and the GitHub signing-key lookup; the full list is in the threat model. The vendor CLIs do send usage data by default; that is their setting, not maruhi’s. maruhi sync switches it off for the vendor process it starts (it never starts the Netlify CLI), and maruhi push does the same for gh when it triggers a workflow (GH_TELEMETRY=false, DO_NOT_TRACK=1, and no update check). For the shell recipes, switch it off once and for all with wrangler telemetry disable, vercel telemetry disable, and gh config set telemetry disabled, or for a single run set WRANGLER_SEND_METRICS=false, VERCEL_TELEMETRY_DISABLED=1, or GH_TELEMETRY=false in your shell.

© 2026 maruhi contributors

Type to search…

↑↓ navigate↵ selectEsc close