deploy.sh needs DEPLOY_TOKEN, and the ops team left it in ~/staging-token.txt. A token written in the repository is readable by everyone who can read the code, forever, history included. It goes in a secret: GitHub stores it, and hands it to the runs that use it. Anyone who can push to the repository can use its secrets in a workflow, so only give write access to people you'd trust with them.
gh secret set
Stores a secret for the repository. Its value comes from a file (or a pipe); typed alone, gh asks for it, hidden.
gh secret set DEPLOY_TOKEN < ~/staging-token.txt
gh secret listgh secret list shows the names, never the values. GitHub hides a secret's exact value in logs as ***, but only that exact text: never print a secret, or anything made from it. A step gets the value from the secrets context, usually through env::
- run: ./deploy.sh staging
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}The Deploy workflow already does that. Once the secret is set, run it again: gh workflow run deploy.yml.
Objectives
- Deploy with a secret.
- What does the log show where the token goes?