GitHub Action · canary analysis

Is this deploy safe?
Let the pipeline decide.

deploy-gate compares a canary's real metrics with the version already serving traffic and returns promote rollback or extend, with a report that says why. Missing or thin data does not promote: the gate waits, then rolls back at the time limit.

Why

Deploys are cheap, judgment is not

Most teams ship a canary, open a dashboard and decide by eye. That depends on who is watching, how tired they are and which graph they happened to open.

Fixed thresholds lie

"Alert if errors exceed 1%" fires at peak traffic and stays quiet at night. Comparing the canary with the current version over the same minutes cancels those patterns out.

Noise is real

With little traffic, one bad request looks like a 5% error rate. A check fails only when the canary is worse by more than the tolerance you chose, with confidence. Over the whole wait, a canary within a tolerance fails that check in at most alpha of runs, a rate you choose (about twice that across an error and a latency check). For the error rate this holds when requests fail independently of each other; for latency, when the canary's latency is the baseline's scaled by one factor and a group that is slow in one minute is not more likely to be slow in the next. Errors that come in bursts are outside it: a bad minute that has not happened yet cannot be seen, which is what the minimum bake time is for. So is latency that stays high or low for many minutes in one group: the gate counts such minutes as fewer before it passes, and a canary at the tolerance still promotes more often than alpha then. The rates behind this are simulated, not measured in production, and the design document lists them.

"Ready" is a gate the system passes, not a feeling.

How it works

Select a step to see what happens there, or press play to walk through them.

Try it

Synthetic traffic, real decision code: this page runs the same src/core the action ships. Pick a scenario or move the sliders.

What is different from a real run: this is one look at alpha 0.01 on every minute up to the slider, with no settle lag. The action looks every few minutes, divides alpha over those looks (0.05 / 7 for the error rate and 0.05 / 5 for latency with the defaults), and leaves out the newest two minutes. So a scenario that promotes here can still be waiting at the same minute in a real run. As in the action, nothing promotes before the minimum bake time (15 minutes), and the errors here are independent across requests: a canary whose errors come in bursts is a case the tests on the totals do not bound.

Check Verdict p (worse than the tolerance) p (within the tolerance) Reason

baseline p99 canary p99 (per minute)

How to use it

  1. Give the workflow read-only access to CloudWatch

    Create an IAM role GitHub can assume through OIDC, allowed only cloudwatch:GetMetricData and cloudwatch:ListMetrics. No long-lived keys; the action never writes to AWS.

  2. Describe your checks

    # .github/deploy-gate.yml
    source: cloudwatch
    maxDurationMinutes: 30
    checks:
      - { name: errors, kind: error-rate, maxAbsoluteIncrease: 0.005 }
      - { name: latency-p99, kind: latency, statistic: p99, maxRelativeIncrease: 0.10 }
    groups:
      canary:   { dimensions: { TargetGroup: targetgroup/app-canary/abc, LoadBalancer: app/main/123 } }
      baseline: { dimensions: { TargetGroup: targetgroup/app-stable/def, LoadBalancer: app/main/123 } }
  3. Call it after the canary deploy, and act on the decision

    - id: gate
      uses: pablomagnaghi/deploy-gate@v1
      with:
        canary-started-at: ${{ steps.canary.outputs.started-at }}
        fail-on-rollback: false
    - id: promote
      if: steps.gate.outputs.decision == 'promote'
      run: ./scripts/shift-traffic.sh 100
    # always(): also after a failed gate step, a cancelled job or a failed promote
    - if: always() && (steps.gate.outputs.decision != 'promote' || steps.promote.outcome != 'success')
      run: ./scripts/shift-traffic.sh 0

    By default the action waits and looks again every 5 minutes: the window grows until the checks have enough data or the time limit rolls back. With wait: false it returns extend and the workflow calls it again. The examples/ folder wires this up for ALB weights and Lambda aliases. @v1 is the tag the first release will create; until then, pin a commit SHA.

  4. Read the report

    Every look is logged as it ends, and every run writes a job summary: the decision, a headline that says whether a check failed or the canary was only not confirmed in time, the reason, one row per check with the numbers, both p-values (worse than the tolerance, and within it) and the alpha they were compared with, and a table of the looks, so anyone can verify it by hand.

Principles