Skip to content
Latchkey

GitHub Actions Workflow for Reusable Workflow

Define CI once and call it from many repos or workflows.

This is a reusable workflow triggered by workflow_call, plus a caller that passes inputs and secrets.

The workflow

.github/workflows/reusable-ci.yml
name: Reusable CI
on:
  workflow_call:
    inputs:
      node-version:
        type: string
        default: '20'
    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
      - run: npm test
---
# .github/workflows/ci.yml (caller)
name: CI
on: [push]
jobs:
  call:
    uses: ./.github/workflows/reusable-ci.yml
    with:
      node-version: '22'
    secrets:
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Notes

  • The reusable file declares on: workflow_call with typed inputs and secrets.
  • Callers reference it by path with uses: and pass with: / secrets:.
  • Centralizes CI logic so updates propagate to all callers.

Run it cheaper

Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.

Related guides

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