What are reusable workflows and how do you call one?
IntermediateConceptGitHub Actions
Answer
A reusable workflow is a workflow with on: workflow_call, defining typed inputs, secrets and outputs. Callers use it at the job level with uses:, referencing a path in the same repo or org/repo/.github/workflows/file.yml@ref.
# .github/workflows/build.yml (callee)
on:
workflow_call:
inputs:
node-version: { type: string, default: '22' }
secrets:
NPM_TOKEN: { required: false }
# caller
jobs:
build:
uses: my-org/platform-workflows/.github/workflows/build.yml@v3
with: { node-version: '20' }
secrets: inherit
Pin callers to a tag or SHA, not main.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate