Skip to content
Latchkey

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.TOKEN

Common 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

  1. Read the contexts table to see what is available for each key.
  2. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →