Blog

Don't echo a secret in a GitHub Actions run

run: echo ${{ secrets.API_KEY }} puts the secret in the script output. The check reads the workflow. It does not run the job.

The echo is the finding

The line is `run: echo ${{ secrets.API_KEY }}`. The workflow-prints-a-secret check looks for a run script that echoes or prints a `${{ secrets. }}` expression. It reads the workflow YAML. It does not run the workflow.

`run: echo "hello"` is not this finding. An env mapping that names `secrets.GITHUB_TOKEN` and does not print it is not this finding either.

Take it out of the script output

The suggested next step is to remove the secret from the script output. If the step needs the value, set it on `env` and use that name in the command. Don't echo the `${{ secrets. }}` expression.

Echoing a shell variable that holds the secret is not the line this check looks for. I would still block that echo in review. Search the workflow for `secrets.` inside a `run` script. That expression is the line to delete. Copying `.env` into an image is a different check.

More from the blog

Keep going