Skip to content
Latchkey

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 green

Notes

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →