C.W.K.
Stream
Lesson 12 of 13 · published

Rollback

~11 min · rollback, incident, recovery

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Rollback is its own workflow, not an afterthought

If your only rollback option is 'redeploy the previous commit', you'll find out during an incident that the previous commit's image is gone, the migration can't be reversed, and the rollback path nobody tested doesn't exist. Build the rollback workflow before you need it.

What rollback actually means

Different deploy targets have different rollback shapes:

  • Container orchestrator (ECS, Kubernetes) — re-deploy the previous task definition / deployment manifest. Fastest.
  • Static site (Vercel, Netlify, Pages) — promote the previous deploy. UI button or API.
  • Lambda — point the alias to the previous version.
  • Custom VPS deploy — symlink swap, git checkout <previous> and re-run the deploy script.

The rollback workflow

  • workflow_dispatch with input version: choice populated from the last 10 deploys.
  • Or: triggered automatically by if: failure() on the smoke job.
  • Posts a Slack/email alert with the chosen version and the operator.
  • Always runs the smoke after rollback — verify the rollback itself worked.

Things rollback can't fix

  • Schema changes already applied — you need a forward-fix migration.
  • Data already mutated — point-in-time recovery if available, or accept the loss.
  • External systems already notified (emails sent, payments charged) — those don't un-happen.

Code

Manual rollback workflow·yaml
name: rollback
on:
  workflow_dispatch:
    inputs:
      version:
        type: string
        required: true
        description: 'SHA or tag to roll back to (e.g., abc1234)'
      reason:
        type: string
        required: true
        description: 'Why are we rolling back?'

jobs:
  rollback:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      id-token: write
      contents: read
    steps:
      - run: echo "Rolling back to ${{ inputs.version }} — reason: ${{ inputs.reason }}"
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123:role/gha-deploy-prod
          aws-region: us-east-1
      - run: ./deploy.sh ${{ inputs.version }}
      - run: ./tests/smoke.sh
      - name: Notify
        if: always()
        run: ./notify-slack.sh "Rollback to ${{ inputs.version }}: ${{ job.status }}"

External links

Exercise

Build a manual rollback workflow for one of your services. Schedule a half-hour next week to test it in staging. Document anything that didn't work the first time.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.