GitHub Actions cannot use needs in a reusable workflow input
When calling a reusable workflow, the with inputs are evaluated in the caller. The needs context is available for that, but inside the called reusable workflow you cannot reference the caller’s needs - only the inputs context, so values must be passed in explicitly.
What this error means
A reusable workflow errors or reads empty because it references needs, which is not in scope inside the called workflow.
github-actions
# inside the reusable workflow (.github/workflows/deploy.yml)
on:
workflow_call:
inputs:
tag: { required: true, type: string }
jobs:
go:
steps:
- run: echo "${{ needs.build.outputs.tag }}" # needs not available hereCommon causes
needs context is caller-scoped
The called workflow has its own job graph; it cannot see the caller’s needs.
Expecting upstream outputs without passing them
Outputs from the caller must be forwarded as inputs to the reusable workflow.
How to fix it
Pass the value as an input from the caller
- In the caller, read needs.<job>.outputs and pass it via with.
- Reference inputs.<name> inside the reusable workflow.
.github/workflows/ci.yml
# caller
jobs:
deploy:
needs: build
uses: ./.github/workflows/deploy.yml
with:
tag: ${{ needs.build.outputs.tag }}Use inputs context inside the reusable workflow
- Replace needs references with inputs.<name> in the called workflow.
- Declare the input under on.workflow_call.inputs.
How to prevent it
- Treat reusable workflows as functions: pass everything via inputs.
- Do not rely on caller context (needs) inside the callee.
Related guides
GitHub Actions Reusable Workflow Input Type MismatchFix GitHub Actions reusable workflow input type errors - passing a string where boolean or number is declared…
GitHub Actions reusable workflow required input not provided by the callerFix a workflow_call validation error when the caller omits an input declared required: true by the reusable w…
GitHub Actions needs.<job>.outputs Undefined Across JobsFix GitHub Actions needs.<job>.outputs returning empty - the upstream job never mapped its step output to a j…