Missing secrets are not an error in GitHub Actions but an empty string. If a secret only lives in an environment, a job only sees it once it names that environment – otherwise it runs on with an empty value.
Symptom
gh run view <ID> --log | grep 'Z Länge'
r8 Run echo "Länge: ${#DEPLOY_TOKEN}" ... Länge: 0
The job prints the length of the token (“Länge” = length) – it is 0. Then test -n fails.
Diagnosis
Check whether the secret lives in the repository or in an environment.
gh secret list gh secret list --env produktion
Causes
environment secretThe secret lives in the environment, not the repository
DEPLOY_TOKEN is a secret of the environment produktion. Without environment: produktion the job cannot see it.
empty stringMissing secrets are not an error
${{ secrets.X }} simply returns an empty string for an unknown secret – the job runs on until something fails with the empty value.
Fix
environment: produktion
echo "Länge: ${#DEPLOY_TOKEN}"
test -n "$DEPLOY_TOKEN"
Don't: Also copy the secret into the repository – then every workflow bypasses the environment's protection rules (approval, branch restriction).
GitHub Actions hands-on, Day 15: find and fix eight broken workflows against the clock.
Go to day 15 →
FAQ
Why does the run need an approval afterwards?
The environment produktion requires an approval (Day 10). Every job that names it waits for it.
How do I notice empty secrets early?
With test -n "$VAR" as the first command – the step then fails immediately with a clear cause.