Reusable Workflows: Pipeline DRY Done Right
Pipeline duplication compounds across repos. Reusable workflows fix it without trading flexibility.
Why duplicate pipelines hurt
Per-repo pipelines drift. The security check on repo A passes; on repo B it is six months out of date.
One reusable workflow; updated centrally; all repos inherit. The maintenance is bounded.
Reusable patterns
- GitHub:
workflow_call+ composite actions. - GitLab:
includefrom a shared repo. - Jenkins: shared libraries.
Versioning shared workflows
Pin to a tag (e.g., @v3); centrally bump; PRs to consumers verify still working.
Avoid @main for shared workflows; surprise breakage.
When to NOT reuse
One-off pipelines for special workloads should not force into the shared template.
“90% reusable + 10% custom” is healthy; “100% reusable always” is rigid.
Antipatterns
- Copy-pasted pipelines across 50 repos. Drift; security debt.
- Pinning to @main. Surprise outages.
- Reuse forced where it does not fit. Workarounds proliferate.
What to do this week
Three moves. (1) Apply this to one pipeline first. (2) Measure deploy frequency / MTTR before/after. (3) Document the outcome so the next team starts from data.