World map

 

BM: Baca dalam Bahasa Melayu

World C3: Release & Deploy

Smoke tests and auto rollback

You will learn: how to taste a deploy right away, and let the pipeline undo a bad one by itself.

Checked with GitHub Actions 2026-10 on 31 Oct 2026

The problem

The deploy goes green. The live site shows an error page. Which station will stop this line? Tap one, then run.

Which station will stop the line? Tap it, then press Run.

What happened on GitHub

Workflow file .github/workflows/deploy.yml

name: Deploy
on:
push:
branches: [main]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm ci
- run: npm run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- run: curl --silent https://shop.example.com/health

The line

Push to main · main

Watch

A smoke test: A quick taste right after a deploy: does the page load, does /health say ok? is one quick taste right after a deploy. Not the whole menu, one spoon. Good smoke tests, or not?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4

Ask /health and expect 200 OK.

Ask /health and expect 200 OK.

Try it

Fix the check from the first card. Build a curl that fails on an error page.

Tap the pieces in the right order.

…

Watch

Add a rollback: Go back to the last good version, like serving yesterday's good batch again. job: it runs only if: failure(). Here the canary’s smoke test meets an error. Which station stops the line? Tap, then run.

Which station will stop the line? Tap it, then press Run.

What happened on GitHub

Workflow file .github/workflows/release.yml

name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
jobs:
canary:
runs-on: ubuntu-latest
environment: canary
steps:
- uses: actions/checkout@v7
- run: npm ci
- run: npm run deploy -- --env canary
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- run: curl --fail --silent https://canary.example.com/health
production:
needs: canary
runs-on: ubuntu-latest
environment:
name: production
url: https://shop.example.com
steps:
- uses: actions/checkout@v7
- run: npm ci
- run: npm run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
rollback:
needs: canary
if: failure()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm ci
- run: npm run rollback
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

The line

Push tag v1.3.1 · v1.3.1

Try it

Build it yourself: deploy, taste, and roll back on failure.

Tap blocks to add them. Put them in order.

Blocks

Your workflow

Tap a block above to start.

Workflow file .github/workflows/

name: Deploy

What runs

Nothing to run yet.

Predict

Next week, the smoke test passes. What does the rollback job do?

Pick one answer.

You did it!

You can now catch a bad deploy and undo it automatically.

Go deeper (optional)

wrangler rollback swaps the code, not the data. Databases and other bindings stay as they are. Pair it with expand and contract. Want to taste before any user does? Deploy a version at 0%, then call it with the Cloudflare-Workers-Version-Overrides header.

Real rep (optional): give a test Worker a /health page and a curl check.