Skip to content
Latchkey

GitHub Actions "env context ... not available" with uses reusable workflow in CI

When you call a reusable workflow, the with: and secrets: maps are evaluated in a limited context. The env context is not available there, so ${{ env.X }} in a caller with: value fails to parse.

What this error means

Parsing fails with "Unrecognized named-value: 'env'" or "the env context is not available" on a with: or secrets: value that references env. under a calling job.

GitHub Actions
Invalid workflow file: .github/workflows/ci.yml#L9
Unrecognized named-value: 'env'. Located at position 1 within expression: env.REGION
The env context is not available in job-level "with" when calling a reusable workflow.

Common causes

A with: value references env

Caller inputs are computed before the job runs, so the per-job env map does not exist yet. ${{ env.REGION }} in with: cannot resolve.

Expecting env to flow into the called workflow

Environment variables set in the caller do not propagate into the reusable workflow; only declared inputs and (with inherit or explicit passing) secrets do.

How to fix it

Pass the value through inputs or vars

  1. Declare an input on the reusable workflow for the value.
  2. In the caller, pass a literal, a vars. value, or a needs.*.outputs value, not env..
  3. Read it inside the called workflow as ${{ inputs.region }}.
.github/workflows/ci.yml
jobs:
  deploy:
    uses: ./.github/workflows/deploy.yml
    with:
      region: ${{ vars.REGION }}

Compute the value in an upstream job output

If the value is dynamic, produce it as a job output and reference it via needs, which is available in the calling context.

.github/workflows/ci.yml
with:
  region: ${{ needs.setup.outputs.region }}

How to prevent it

  • Use inputs, vars, needs, and github in caller with:/secrets:, never env.
  • Define an explicit input for every value a reusable workflow needs.
  • Compute dynamic values as job outputs upstream of the call.

Frequently asked questions

What causes ""Unrecognized named-value: env""?
Caller inputs are computed before the job runs, so the per-job env map does not exist yet. ${{ env.REGION }} in with: cannot resolve.
How do I fix "Unrecognized named-value: env"?
Pass the value through inputs or vars

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card