- Symptom
- Unrecognized named-value: 'secrets'. Located at position 1 within expressionWorkflow is invalid before it runsAn if condition that reads secrets.TOKEN is never evaluated
- Cause
- The secrets context is not allowed in jobs.ID.if or in step if conditions. Only contexts listed for each key are available there.
- Fix
- Map the secret into env at job level and test env in the step condition.
- Apply
jobs: publish: runs-on: ubuntu-latest env: HAS_TOKEN: ${{ secrets.NPM_TOKEN != '' }} steps: - if: env.HAS_TOKEN == 'true' run: npm publish- Affected
- GitHub Actions workflow syntax, as of October 2026
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders