GitHub Actions Workflow for Blue-Green Deploy
Deploy to the idle color, verify, then flip traffic.
This workflow deploys to the inactive environment, runs smoke tests, and switches the load balancer for a zero-downtime cutover.
The workflow
.github/workflows/blue-green.yml
name: Blue-Green Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Deploy to idle color
run: ./deploy.sh --target green
- name: Smoke test idle color
run: ./smoke-test.sh --target green
- name: Switch traffic
run: ./switch-lb.sh --to greenNotes
- Deploy to the idle color so the live one keeps serving.
- Smoke-test before the traffic switch -- a failed check aborts the flip.
- Rollback is just flipping the load balancer back.
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
GitHub Actions Workflow for Canary DeployA GitHub Actions workflow that performs a canary deploy -- shifting a small traffic slice first, then promoti…
GitHub Actions Workflow for Promote an Image Across EnvironmentsA GitHub Actions workflow that promotes the exact same Docker image digest from staging to production without…
How to Speed Up GitHub Actions: 9 High-Impact TacticsMake GitHub Actions faster: caching, parallelization, test splitting, Docker layer caching, slimmer images, a…