Skip to content
Latchkey

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_call with inputs: and secrets: to the reusable workflow.
  • In the caller, set uses: to the workflow path and @ref.
  • Pass values with with: and forward secrets with secrets:.

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: inherit to forward all caller secrets without listing each.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →