# CI pipelines

CI systems hold some of your most powerful secrets, and attacks on them are common: a malicious workflow change, a compromised action or package, a leaked token. Give each CI system, or each repository that matters, one canary stored with its real secrets.

## GitHub Actions

Pipe the decoy straight into the repository's secrets. `gh` prints the names it set, never the values:

```sh
curl -fsSL https://get.snitchwallet.com | sh -s -- --decoy env:- --name github-ci | gh secret set -f - --repo OWNER/REPO
```

For a deployment environment's secrets, add `--env production`. For every repository in an organization, use `--org ORG --visibility all` instead of `--repo`.

That alone catches anyone who gets write access and adds a workflow that dumps the repository's secrets. GitHub only gives a job the secrets its workflow names, so to also catch a compromised action or package inside your real jobs, put the canary in their environment. `gh secret list --repo OWNER/REPO` shows the two names it chose (never the values); use them like this:

```yaml
jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      PAYOUT_WALLET_WIF: ${{ secrets.PAYOUT_WALLET_WIF }}
      PAYOUT_WALLET_NETWORK: ${{ secrets.PAYOUT_WALLET_NETWORK }}
```

## GitLab CI

`glab variable set` reads a value from stdin and never prints it, one variable at a time. Run this in a clone of the project. The key is masked in job logs; the network name is too short for GitLab to mask, and isn't secret anyway:

```sh
curl -fsSL https://get.snitchwallet.com | sh -s -- --decoy env:- --name gitlab-ci \
  | while IFS='=' read -r name value; do
      case "$name" in *_WIF) mask=--masked ;; *) mask= ;; esac
      printf '%s' "$value" | glab variable set "$name" $mask
    done
```

Add `--group YOUR-GROUP` to set it for every project in a group. GitLab passes variables to every job, so unlike GitHub there's nothing to map. If you add `--protected`, only jobs on protected branches and tags get it.

## Other CI systems

CircleCI, Bitbucket Pipelines, Jenkins, Buildkite, Azure Pipelines and others keep secrets in their web settings or in their own secret store. Write the decoy to a file only you can read, add the two `NAME=value` lines as secrets or environment variables, then delete the file:

```sh
umask 077
curl -fsSL https://get.snitchwallet.com | sh -s -- --decoy env:- --name circleci > decoy.env
```

If your CI reads secrets from a cloud secret manager or Vault, store the canary there instead: see [AWS](/docs/aws), [Google Cloud and Azure](/docs/gcp-azure) and [Secret managers](/docs/secret-managers).

## Self-hosted runners

A long-lived build machine is a server: give it a [per-machine canary](/docs/servers) too, so the alert names the runner when someone breaks out of a job onto it.
