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.
Prerequisites
Section titled “Prerequisites”- The
keypastecommand on your computer and in the CI image (install the CLI). - Your CI’s secret store, such as GitHub Actions secrets.
1. Make a vault for the pipeline
Section titled “1. Make a vault for the pipeline”On your own computer:
keypaste init ci.kdbxKEYPASTE_VAULT=ci.kdbx keypaste env set ci DATABASE_URLNew master password:Confirm master password:Created /home/you/ci.kdbxMaster password:Value for DATABASE_URL:Set DATABASE_URL on env/ci/.env, created and tagged env:ciGive 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.
2. Store the master password
Section titled “2. Store the master password”Add the master password to your CI’s secret store, for example as KEYPASTE_MASTER.
3. Pipe it to keypaste run
Section titled “3. Pipe it to keypaste run”In GitHub Actions:
env: KEYPASTE_VAULT: ci.kdbxsteps: - 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.
Instead of a password: a scoped token
Section titled “Instead of a password: a scoped token”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:
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.
Next steps
Section titled “Next steps”- keypaste token and keypaste run: scopes, bundles, protected stages and every option
- kp:// references
- Use your vault’s env in a project