How to Reuse a Workflow With workflow_call in GitHub Actions
workflow_call turns a workflow into a callable unit other workflows invoke like an action.
Define on.workflow_call with inputs and secrets in the reusable file, then reference it from a caller job via uses: owner/repo/.github/workflows/file.yml@ref.
Steps
- Add
on.workflow_callwithinputs:andsecrets:to the reusable workflow. - In the caller, set
uses:to the workflow path and@ref. - Pass values with
with:and forward secrets withsecrets:.
Caller workflow
.github/workflows/ci.yml
jobs:
call-build:
uses: my-org/ci/.github/workflows/build.yml@main
with:
node-version: '20'
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}Gotchas
- Reusable workflows can nest up to four levels deep.
- Use
secrets: inheritto forward all caller secrets without listing each.
Related guides
How to Create a Composite Action in GitHub ActionsBundle several steps into one reusable composite action in GitHub Actions with runs.using composite and an ac…
How to Manually Trigger a Workflow With Inputs in GitHub ActionsAdd a manual Run workflow button in GitHub Actions with workflow_dispatch and typed inputs, then read the val…