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.
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
- Declare an input on the reusable workflow for the value.
- In the caller, pass a literal, a
vars.value, or aneeds.*.outputsvalue, notenv.. - Read it inside the called workflow as
${{ inputs.region }}.
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.
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.