पाठ 20 / 25
Reusable Workflows
workflow_call.
Call a workflow like a function
A workflow with on: workflow_call declares inputs, secrets and outputs, and other workflows call it as a job with uses: org/repo/.github/workflows/build.yml@ref. This centralises standard pipelines (build, test, deploy) across many repositories so improvements happen in one place. Pass secrets explicitly or with secrets: inherit, pin the reference to a tag or SHA, and keep inputs few and well documented.
Share automation, ship safely
Reusable workflows and composite actions remove duplication; environments add approvals to deployments.
Defining and calling a reusable workflow
Not linted or run here; check the GitHub Actions documentation for current syntax.
# .github/workflows/node-ci.yml (in a shared repo)
on:
workflow_call:
inputs:
node-version: { type: string, default: "22" }
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: "${{ inputs.node-version }}", cache: npm }
- run: npm ci && npm test
# caller
jobs:
ci:
uses: acme/workflows/.github/workflows/node-ci.yml@v1
with: { node-version: "20" }Version shared workflows
Tag releases of shared workflows so teams can upgrade deliberately.
त्वरित जाँच: Which trigger makes a workflow callable by other workflows?
- workflow_dispatch
- workflow_call
- repository_dispatch
- push
Answer
workflow_call — Reusable workflows are called as jobs.