Skip to main content

Gitslice docs

Secrets

Store tokens, API keys, and passwords encrypted in Gitslice and scope them to folders — for CI checks, automations, Git mirrors, and local env files — without ever committing credentials.

How secrets work

  • Folder-scoped under an account: A secret belongs to a personal or organization account and applies to the folders you attach it to plus everything below them (for example, /acme/services/billing). Attaching it to /acme covers the entire account.
  • Injected into checks, automations, and mirrors: CI checks read secrets as environment variables matching the secret name (such as DEPLOY_TOKEN), based on the folder of the .gitslice/checks.yaml that defines the check. A secret overrides a check's own env entry of the same name. Automations and Git mirrors reference the same folder and slice secrets by name. Checks only receive secrets when running on the account's CI runner pool (or slice override).
  • Closest folder wins: A folder holds at most one secret per name. When multiple ancestor folders define the same name, the closest folder takes precedence: a DEPLOY_TOKEN on /acme/web overrides one on /acme for anything under /acme/web.
  • Encrypted and masked in logs: Values are stored encrypted, never shown in the web UI, and masked as *** in check and automation logs (multi-line values are masked line by line; values shorter than 4 characters are not masked).

Add and manage secrets

In the web app, open Policy → Secrets on any folder while browsing to see inherited secrets or add one to that folder, or open Secrets on your account page to manage every folder secret in one place. From the CLI, pipe the value via stdin (omitting --path inside a workspace defaults to the current folder):

# inside a workspace folder, defaults to the current folder
printf %s "$TOKEN" | gs secret create WEB_TOKEN

# scope to specific folders in your active account (pass --account for another)
printf %s "$TOKEN" | gs secret create DEPLOY_TOKEN --path /acme/api --path /acme/worker

# scope to the whole account monorepo
printf %s "$NPM_TOKEN" | gs secret create NPM_TOKEN --path /acme

gs secret ls                                       # names, folders, last updater
gs secret update <secret-id> --add-path /acme/web  # or --remove-path, --path
printf %s "$NEW" | gs secret update <secret-id> --value
gs secret rm <secret-id>

Secret names follow environment variable rules: uppercase letters, digits, and _, not starting with a digit. Values can be up to 48 KiB (large enough for certificates or key files). Each secret can attach to up to 50 folders, and an account can store up to 200 secrets.

One slice at a time

gs slice secret operates strictly on a slice's included folders so you never accidentally alter a secret shared with other folders:

gs slice secret ls acme/api                      # names that apply in the slice
printf %s "$TOKEN" | gs slice secret set acme/api CI_TOKEN
gs slice secret rm acme/api CI_TOKEN             # detach the slice's folders from the secret

set refuses to overwrite a secret that also applies outside the slice (use gs secret update instead). rm refuses to remove a secret inherited from a folder above the slice, such as the account root, because doing so would affect sibling folders.

Who can see what

WhoWhat they can do
Account owners and adminsCreate, update, move, and delete secrets. Render values into a local mode-600 env file with gs secret env.
Slice writers and slice adminsList secret names that apply in the slice (gs slice secret ls). Their changesets' checks receive secret values, and they can allow contributor patchsets via gs check allow, but they cannot read raw values out.
Slice contributorsCannot list secret names or values. Their changesets' checks run without secrets until a writer or admin runs gs check allow.
Readers and everyone elseNo access to secret names or values.

Choose folders and roles with care. A check executes commands from its changeset, so any writer of a slice that includes a secret's folder (or a folder above or inside it) can access that secret during CI, and that slice's CI daemon receives it too. Log masking (***) catches accidental prints, not deliberate exfiltration such as base64-encoding a value. Attach secrets only to folders whose writers you trust, and assign external collaborators or autonomous agents the contributor role so their patchsets run secretless until explicitly allowed with gs check allow.

Fill a local env file

When local tasks such as manual deploys need the same secrets, commit a template file with public config written out and secret values marked as placeholders:

# env.prod.template
PUBLIC_API_BASE_URL=https://api.example.com
CLOUDFLARE_API_TOKEN=gitslice-secret:CLOUDFLARE_API_TOKEN
R2_SECRET_ACCESS_KEY=gitslice-secret:R2_SECRET_ACCESS_KEY

Account owners and admins fill the template locally. Inside a workspace, secrets are resolved from the template's folder automatically; outside a workspace, pass --path:

gs secret env acme/api/env.prod.template -o .env.prod    # inside a workspace
gs secret env env.prod.template --path /acme/api -o .env.prod
  • The output file is written with permissions 0600 (readable only by you). gs refuses to print secret values directly to a terminal and will not overwrite an existing file without --force.
  • If any placeholder references a secret that does not apply at the target folder, nothing is written. Values containing shell metacharacters are quoted so the output can be sourced safely.
  • Only account owners and admins can run gs secret env, and every read is audit-logged with the caller and secret names. Everyone else should work from an example env file without production credentials.
  • After rotating a credential, update the secret and regenerate the local file. Keep generated env files out of source control via .gitignore.

Gitslice deploys its own web app using this pattern — see env.prod.template in the gitslice/gitslice slice.

CI Checks

Define the checks that consume these secrets and run a CI daemon.

Automations

Use folder secrets to sign webhooks, call external APIs, or run secure bash runbooks.