GitHub Actions "Unrecognized named-value: secrets"
An expression referenced a context that is not allowed at that position. Each workflow key permits a specific set of contexts.
What this error means
The workflow is rejected with "Unrecognized named-value: 'secrets'" (or another context) on a line where that context is not permitted.
github-actions
The workflow is not valid. .github/workflows/ci.yml (Line: 5): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.TOKENCommon causes
Context used where it is unavailable
secrets cannot be used in runs-on, job-level if at the wrong scope, or concurrency. The set of available contexts depends on the key.
Typo in the context name
Writing secret instead of secrets, or env at a spot that only allows vars, triggers the same error.
How to fix it
Move the reference to an allowed context
- Read the contexts table to see what is available for each key.
- Pass secrets through env: or with: at the step level where they are allowed.
.github/workflows/ci.yml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: deploy
env:
TOKEN: ${{ secrets.TOKEN }}How to prevent it
- Consult the contexts availability table before referencing a context.
- Run actionlint, which knows which contexts are valid per key.
Related guides
GitHub Actions "Unrecognized function" in an expressionFix the GitHub Actions expression error "Unrecognized function" caused by calling a function that does not ex…
GitHub Actions "Context access might be invalid" (actionlint)Fix the actionlint warning "Context access might be invalid" for GitHub Actions caused by referencing a secre…
GitHub Actions "The template is not valid" expression evaluation errorFix the GitHub Actions "The template is not valid" runtime expression evaluation error caused by a function o…