Interview Prep/Real-World Interview/Write-a-pipeline tasks

Write a reusable workflow and call it from another repo.

IntermediateHands-onWrite-a-pipeline tasks
Answer
# org/ci-templates/.github/workflows/node-ci.yml
name: node-ci
on:
  workflow_call:
    inputs:
      node-version: { type: string, default: "22" }
    secrets:
      NPM_TOKEN: { required: false }
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
# service repo
jobs:
  ci:
    uses: org/ci-templates/.github/workflows/node-ci.yml@v1
    with: { node-version: "20" }
    secrets: inherit

Key trick → workflow_call turns a workflow into a callable unit. Pin it with @v1 (or a SHA) so template changes roll out on purpose.

All Real-World Interview questions Roadmap: Interview readiness

More on Write-a-pipeline tasks