# How do I fix "Unrecognized named-value: 'secrets'" in GitHub Actions?

"Unrecognized named-value: 'secrets'" means a context is used at a workflow key where it is not available. Which contexts work where, and four rewrites.

By Grant Unwin, published 2026-11-20. Checked against GitHub's documentation on 2026-11-20. The web page: https://www.runners.io/blog/github-actions-unrecognized-named-value

“Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.TOKEN != ''” means the expression uses a context that does not exist at that key of the workflow file. `secrets` is not available in any `if`, and `env` is not available in `runs-on`. Move the value to a key that allows it, or use a context that is allowed there. A misspelt name gives the same message.

**In short**

- The expression uses a context that is not available at that workflow key, or a misspelt name.
- The position in the message is the character of the expression where the name starts.
- secrets is not available in a job's if or a step's if: set it as job-level env and test env in the step.
- Pass a secret to a reusable workflow under secrets, not with.
- env is not available in runs-on: use vars, or an output of an earlier job through needs.

The name in quotes is the context GitHub did not accept, the position is the character in the expression where it starts, and the expression is printed after it. GitHub rejects the whole file, so no job runs. This post has the table of which contexts are allowed where, four cases of it, and the rewrite for each.

## What does “Unrecognized named-value” mean?

In GitHub’s expression parser a named value is the word at the start of a reference: `github`, `env`, `secrets`, `matrix` and so on. The parser is given the list of names that are valid for the key it is reading, and a name outside the list is an unrecognised named value, whether you misspelt it or it is a real context that does not exist yet at that point. GitHub’s contexts reference says it plainly: different contexts are available at different places in a workflow, and `secrets` may only be used at certain places within a job.

## Which contexts are available where?

GitHub’s contexts reference has a table with one row for every workflow key. These are the rows for the keys this post covers. The middle column is copied from the table, and the last names contexts that are not in that row.

| Workflow key | Contexts available | Not available, for example |
| --- | --- | --- |
| jobs.\<job\_id>.if | github, needs, vars, inputs | secrets, env, matrix |
| jobs.\<job\_id>.steps.if | github, needs, strategy, matrix, job, runner, env, vars, steps, inputs | secrets |
| jobs.\<job\_id>.runs-on | github, needs, strategy, matrix, vars, inputs | env, secrets |
| jobs.\<job\_id>.with.\<input\_id> | github, needs, strategy, matrix, inputs, vars | secrets, env |
| jobs.\<job\_id>.strategy | github, needs, vars, inputs | env, secrets, matrix |
| env (top of the workflow) | github, secrets, inputs, vars | env, matrix, needs |
| concurrency (top of the workflow) | github, inputs, vars | env, secrets, matrix |

Inside a step’s `run`, `with` and `env` nearly everything is available, `secrets` included, which is why the same expression works in one place and is refused two lines up.

## How do I use a secret in an if condition?

You cannot, and GitHub’s documentation gives the way round it: set the secret as an environment variable on the job, then test the variable in the step’s condition. A step’s `if` has the `env` context.

```yaml
jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
    steps:
      - if: env.DEPLOY_KEY != ''
        run: ./deploy.sh
```

This works for steps only. A job’s own `if` has neither `secrets` nor `env`, so a whole job cannot be switched on a secret directly; a report asking for that on GitHub’s runner repository was closed with a maintainer saying it should not be supported. Switch the job on something that is available there instead: a configuration variable through `vars`, or an output of an earlier job through `needs`, as in the last example below.

## How do I pass a secret to a reusable workflow?

Under `secrets`, not under `with`. When a job calls a reusable workflow, its `with` values may use only the contexts in the table above, and `secrets` is not one of them. The job has a separate `secrets` map for this, and the names in it must match the ones the called workflow declares.

```yaml
jobs:
  call:
    uses: octo-org/example-repo/.github/workflows/called.yml@main
    with:
      environment: staging
    secrets:
      token: ${{ secrets.TOKEN }}
```

`secrets: inherit` passes every secret the caller has without naming them. The post on [reusable workflows or composite actions](https://www.runners.io/blog/reusable-workflows-or-composite-actions) has more on how the two receive their inputs.

## Why can’t I use env in runs-on?

Because the `env` context is not in the row for `runs-on` in GitHub’s table. The same goes for a job’s `if`, `strategy`, `concurrency` and `container`. There are two rewrites. If the value is a setting, store it as a configuration variable and read it with `vars`, which is available at every key in the table. If the value has to be computed, compute it in a small first job and read that job’s output through `needs`:

```yaml
env:
  RUNNER: ubuntu-latest

jobs:
  pick:
    runs-on: ubuntu-latest
    outputs:
      runner: ${{ steps.pick.outputs.runner }}
    steps:
      - id: pick
        run: echo "runner=$RUNNER" >> "$GITHUB_OUTPUT"
  build:
    needs: pick
    runs-on: ${{ needs.pick.outputs.runner }}
    steps:
      - run: make
```

`matrix` in a job’s `if` is the same mistake in another place: `matrix` is not in that row either. Put the condition on the steps, or leave the combination out of the matrix with `exclude`, which the [matrix reference](https://www.runners.io/blog/github-actions-matrix-strategy) covers.

## What if the name is spelt wrong?

Then the name in quotes is your spelling: `secret` for `secrets`, `input` for `inputs`, `step` for `steps`. Check that first, since it takes a second. actionlint, an open-source workflow checker, finds both kinds before you push: for each of the broken workflows in this post it named the context and listed the ones allowed at that key.

```bash
actionlint .github/workflows/deploy.yml
# .github/workflows/deploy.yml:6:13: context "secrets" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
```

Two neighbouring messages: a file that does not parse at all gives [“You have an error in your yaml syntax”](https://www.runners.io/blog/github-actions-invalid-workflow-file-yaml-syntax-error), and a step with nothing to do gives [“every step must define a \`uses\` or \`run\` key”](https://www.runners.io/blog/github-actions-every-step-must-define-a-uses-or-run-key). The [security hardening post](https://www.runners.io/blog/github-actions-security-hardening) covers handling secrets once they reach a step.

GitHub evaluates these expressions when it reads the workflow file, so this error is the same whichever runner the jobs name, ours included. Every size we run, with its memory, disk and rate a minute, is on our [managed GitHub Actions runners](https://www.runners.io/runners) page.

## Sources

- [ParseException.cs (actions/runner source)](https://github.com/actions/runner/blob/7e211dc69c347b78fc398e630e74facb11a13235/src/Sdk/Expressions/ParseException.cs#L45)
- [Contexts reference](https://docs.github.com/en/actions/reference/workflows-and-actions/contexts)
- [Using secrets in GitHub Actions](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets)
- [Secrets cannot be used to condition job runs (actions/runner issue 520)](https://github.com/actions/runner/issues/520)
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax)
- [Reuse workflows](https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows)
- [Github Actions reusable workflow doesn't recognize secrets (GitHub Community discussion 69082)](https://github.com/orgs/community/discussions/69082)

## Frequently asked questions

### How do I fix "Unrecognized named-value: 'secrets'" in GitHub Actions?

Move the value to a key where that context is available, or use one that is allowed there. secrets is not available in any if, and env is not available in runs-on. The position, such as 1, is where the name starts in the expression.

### How do I use a secret in an if condition?

You cannot use it directly. GitHub's documentation says to set the secret as a job-level environment variable and test that variable in the step's condition. A job's own if has neither secrets nor env, so use vars or an earlier job's output there.

### How do I pass a secret to a reusable workflow?

Under the calling job's secrets map, not under with, where the secrets context is not available. The names must match the ones the called workflow declares. secrets: inherit passes every secret the caller has.

### What if the name is spelt wrong?

Then the name in quotes is your spelling, such as secret for secrets. Any name the parser does not know at that key gives this message. actionlint reports both a misspelt name and a context used where it is not allowed.
