GH

Reusable Workflows & Composite Actions

DRY workflow patterns, composite actions, and workflow composition

Details

Language / Topic
github-actionsGitHub Actions
Category
Architecture

Rules

balanced
- Create reusable workflows (workflow_call trigger) for shared CI/CD patterns across repositories
- Use composite actions for reusable step sequences within a single job (e.g., setup + build + cache)
- Define clear input/output contracts: use inputs with descriptions and required flags
- Store reusable workflows in a central .github repository for organization-wide sharing
- Prefer reusable workflows over duplicated workflow YAML across repositories
- Reusable workflows (on: workflow_call): shared CI/CD pipelines called from other workflows with inputs/secrets
- Composite actions (action.yml with using: composite): reusable step groups for setup, build, deploy patterns
- Clear contracts: define inputs (descriptions, required, defaults), outputs, and secrets on all reusable components
- Central repository: .github org repo or dedicated actions-* repos for organization-wide workflow sharing
- Reusable > copy-paste: one workflow definition, called from all repos, updates propagate automatically
- Version reusable workflows with tags: uses: org/.github/.github/workflows/ci.yml@v2 for stability
- Pass secrets explicitly: secrets: inherit or named secrets mapping — never rely on ambient secret access
- Composite actions for complex setup: checkout + cache + install + build as one action with clear outputs
- Use strategy matrices in caller workflows for variation (OS, language version) while keeping pipeline DRY
- Document reusable workflows with README, example caller workflow, and input/output specification