StoicBuilder

HandbookX the PortusSecrets in CI

Xthe Portus, Ship it

Secrets in CI

1 min readUpdated 28 November

In plain words

Secrets in CI are the keys and tokens your pipeline uses to test and deploy, stored encrypted in the CI service and handed only to the jobs that need them, never written into the repository.

Where you see it

In GitHub, Settings, then Secrets and variables, then Actions holds secrets like STRIPE_TEST_KEY. A workflow reads one as ${{ secrets.STRIPE_TEST_KEY }}, and GitHub replaces the value with *** if it appears in the log.

.github/workflows/deploy.ymlconfig
deploy: environment: production # its secrets reach only jobs that name it permissions: { contents: read } steps: - run: ./scripts/deploy.sh env: DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
The secret goes to one step in one job, and the production environment can require an approval before that job runs.

What goes wrong

  1. Printing a secret in a form the mask misses

    GitHub hides exact copies of a secret, not the same value base64-encoded, split up or tucked inside a JSON blob. Never echo secrets or turn on verbose logging in steps that use them.

  2. Running untrusted pull requests with secrets

    Workflows triggered by pull_request_target run with your secrets, even for pull requests from forks. Checking out and running the fork's code there hands your keys to a stranger.

  3. Long-lived cloud keys stored as secrets

    An AWS key pasted into secrets works until it leaks, and nobody ever rotates it. Where your cloud supports it, use OpenID Connect so each run gets a short-lived credential instead.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Audit our GitHub Actions workflows: list every secret each job receives, flag any step that could print one, and flag any workflow on pull_request_target that checks out pull request code. Scope each secret to the single step that needs it, and move production secrets into a protected production environment.

Quick check

Sign in to earn +10 XP for it

A Harbor workflow step runs echo $STRIPE_KEY | base64 while debugging. The log shows a long encoded string. Is the key safe?

Got a prompt that touches secrets in CI?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.