How to Reference a Reusable Workflow Output in GitHub Actions
A reusable workflow exposes values through on.workflow_call.outputs, and the caller reads them from the calling job context.
Declare on.workflow_call.outputs mapped to a job output inside the reusable file. The caller then reads needs.<call-job>.outputs.<name>.
Steps
- Map a job output to a
workflow_call.outputsentry in the reusable file. - Call the workflow with
uses:and give the call job an id. - Read
needs.<job>.outputs.<name>in a downstream caller job.
Reusable workflow
.github/workflows/build.yml
on:
workflow_call:
outputs:
image-tag:
value: ${{ jobs.build.outputs.tag }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
steps:
- id: meta
run: echo "tag=sha-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"Gotchas
- The
workflow_call.outputs.valuemust point at a real job output, not a step output directly. - The caller reads the output via
needs, so it mustneeds:the call job.
Related guides
How to Pass a Multiline String as a Step Output in GitHub ActionsWrite a multiline value to GITHUB_OUTPUT in GitHub Actions using a heredoc delimiter, so newlines survive ins…
How to Collect Job Status With needs.result in GitHub ActionsBuild a final gate job in GitHub Actions that inspects each upstream job via needs.<job>.result and the alway…