Lesson 4 of 9 · 24m
Reusable Workflows and Composite Actions That Age Well
How to centralize CI without building a hidden framework nobody can debug, including contracts, inputs, outputs, and versioning discipline.
Every organization reaches the same point: forty repositories copy the same CI YAML, someone fixes a security bug in thirty of them, and the other ten become the incident review. Reusable workflows solve duplication, but badly designed ones become a distributed monolith. Centralize the boring invariant parts, not every decision a team owns.
Reusable workflows are called as jobs
A reusable workflow lives in .github/workflows and uses workflow_call. Callers reference it in a job, not a step.
# platform/ci-workflows:.github/workflows/node-ci.yml
on:
workflow_call:
inputs:
node-version: {required: true, type: string}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- run: npm ci && npm testjobs:
ci:
uses: platform/ci-workflows/.github/workflows/node-ci.yml@v3
with: {node-version: "22"}This gives typed inputs and one implementation. It also means every consumer is affected when you break the central workflow.
Composite actions are shared steps, not shared jobs
name: setup-service
description: Install the service toolchain
inputs: {version: {required: true}}
runs:
using: composite
steps:
- shell: bash
run: ./scripts/install-service.sh "${{ inputs.version }}"Use composite actions for local mechanics: install a toolchain, restore a cache, configure cloud credentials. Use reusable workflows for policy: the shape of CI, required checks, and release gates. If you need to control job placement, permissions, or environments, a composite action is the wrong abstraction.
Versioning is a compatibility contract
Consumers pin to tags or SHAs. Treat inputs and outputs as a public API. Add inputs with defaults rather than changing meaning. When you must break compatibility, create a new major tag and document migration.
uses: org/shared-actions/setup-service@1f04d8e91f69a3a6c4f765bb34df5a3c59a3b2ca is immutable; @main is not. A full SHA is the strongest pin, while a major tag is easier but mutable unless tightly controlled.
Shared CI also needs observability: errors appear in consumer repositories while bugs live centrally. Emit the central workflow version in logs, link runbooks, and keep escape hatches; a required workflow with no override is an organizational single point of failure.
Field notes
- Reusable workflows can call other reusable workflows, but deep nesting becomes impossible to debug; keep the graph shallow.
- Secrets are not automatically passed. Use
secrets: inheritonly when the callee genuinely needs the same trust level. workflow_callcannot read arbitrary caller files until checkout happens inside the callee job.- Good shared CI exposes decisions as inputs. Bad shared CI hides decisions behind conventions nobody remembers.
Was this lesson helpful?