Skip to content

Run in CI

Your CI job will start its command with an environment’s variables from a vault that holds only what the pipeline needs.

  • The keypaste command on your computer and in the CI image (install the CLI).
  • Your CI’s secret store, such as GitHub Actions secrets.

On your own computer:

Terminal window
keypaste init ci.kdbx
KEYPASTE_VAULT=ci.kdbx keypaste env set ci DATABASE_URL
New master password:
Confirm master password:
Created /home/you/ci.kdbx
Master password:
Value for DATABASE_URL:
Set DATABASE_URL on env/ci/.env, created and tagged env:ci

Give it a long random master password. A vault committed to a public repository can be guessed offline for as long as it exists, so keep it out of the repository if you can.

Add the master password to your CI’s secret store, for example as KEYPASTE_MASTER.

In GitHub Actions:

env:
KEYPASTE_VAULT: ci.kdbx
steps:
- run: printf '%s\n' "$KEYPASTE_MASTER" | keypaste run --no-session ci -- npm test
env:
KEYPASTE_MASTER: ${{ secrets.KEYPASTE_MASTER }}

keypaste run reads one line of standard input as the master password and leaves the rest to your command. The job’s log shows only your command’s output, and its exit code is the step’s.

Without a terminal, commands that ask before acting, such as env pull and env rm, need --yes.

A scoped token releases one environment’s stage, without the master password, through the process holding the vault. Making one changes the vault, so lock it in the app or stop keypaste approve first, then:

Terminal window
keypaste token create ci-staging --scope 'read:acme-api/staging/*'

Store the printed token as a CI secret, pass it as KEYPASTE_TOKEN, and run keypaste run --token env -p staging acme-api -- npm test. It works for 30 days unless --ttl says otherwise. For a job that can’t reach the computer holding the vault, keypaste token bundle seals a file that keypaste run --bundle opens with the token alone.

The values are in your command’s environment, so it, its child processes and its logs can read them. Rotate a value that reached a log.