Interview Prep/CI/CD/GitHub Actions

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.

All CI/CD questions

More on GitHub Actions