Lesson 9 of 9 · 27m
Production Release Patterns: Rolling, Blue-Green, Canary, and Monorepos
How to choose a deployment topology, encode it in Actions, and adapt pipelines for monorepos without turning every commit into a full-stack release.
There is no universally correct deployment pattern. Rolling deployment is simple and can strand users on mixed versions. Blue-green gives fast cutover but doubles infrastructure. Canary reduces blast radius but requires observability mature enough to notice harm. Actions should encode the pattern honestly, not pretend one YAML file makes the underlying risk disappear.
Rolling deploys: simple, ordered, imperfect
Rolling deployment replaces instances gradually. Encode ordering and failure stops explicitly.
strategy:
fail-fast: true
matrix:
target: [web-1, web-2, web-3]
steps:
- run: ./release/deploy-host.sh "${{ matrix.target }}"Be careful: matrix jobs run in parallel, so this YAML does not implement rolling order. For true rolling behavior, use a loop inside a controlled deployment script or separate jobs connected with needs. Do not let YAML cosmetics hide parallel execution.
Blue-green: two production shapes, one cutover
Blue-green keeps two environments. Deploy to idle green, verify, shift traffic, keep blue for rollback.
Traffic shape: load balancer -> blue (current) while green (new) is verified idle.
Actions coordinates the steps: identify green, deploy artifact, run health checks, update routing, record previous version. The dangerous part is state shared between colors — databases, queues, caches. If the new version writes incompatible data, switching traffic back does not undo corruption.
Canary: progressive exposure driven by signals
A canary release sends a small portion of traffic or instances to the new version, observes error rate and latency, then expands.
- run: ./release/set-traffic.sh production 5
- run: ./release/observe.sh production --minutes 10 --max-error-rate 0.5
- run: ./release/set-traffic.sh production 25
- run: ./release/observe.sh production --minutes 10 --max-error-rate 0.5
- run: ./release/set-traffic.sh production 100This only works if observe.sh measures something real. If the health signal is "no exception in the last minute," you built a slow outage. Include business-critical checks when possible: checkout success, message processing lag, login failures.
Monorepos need impact analysis, not blind fan-in
In a monorepo, every push can theoretically affect everything. Running every test and deploying every service is expensive and slow. Detect changed paths against the base SHA, map them to owning services, test affected units plus dependents, produce one release manifest, and deploy only changed artifacts.
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
api: ["services/api/**", "packages/protocol/**"]
web: ["apps/web/**", "packages/ui/**"]Path filters are a heuristic. Keep escape hatches for full builds before releases and after dependency or toolchain changes.
Field notes
- Mixed-version compatibility is the hidden requirement in every rolling deployment.
- Blue-green is not safer if both colors share a stateful system you cannot roll back.
- Canary analysis should use the same dashboards humans trust during incidents, not a parallel toy metrics pipeline.
- Deployment topology belongs in infrastructure code and runbooks first; Actions is the orchestration layer, not the architecture.
Was this lesson helpful?