AI Hints
Home›CI/CD with GitHub Actions Tutorial›Smoke Tests, Rollbacks, and Flags
CI/CD with GitHub Actions · Lesson 95 of 138

Rollbacks

Undo a bad release.

⏱ 2 min read▶ Video at 1:49:43🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

Sometimes a bad release gets through anyway. The fastest fix is usually not a new fix. It's a rollback, putting the last good version back, and then fixing the bug calmly.

Rollbacks
From the video: Rollbacks
  • Bad releases happen
  • Roll back first
  • Fix calmly after

Ways to roll back

If you deploy images with SHA tags, roll back by deploying the previous tag. It's fast, because that image was already built and tested. With blue green, switch traffic back. And in git, revert the bad commit, so the next deploy is good too.

keyvalue
Previous imageredeploy old tag
Blue-greenswitch back
git revertfix main too
Practice itbefore you need it

Reverting in git

A bad commit was pushed. Git revert makes a new commit, that undoes it, without rewriting history. Git log shows both commits, and head shows the file is back to normal. Pushing the revert to main would run the pipeline, and deploy the good code.

Terminal
git log --oneline -1
ca46433 Speed up total
git revert --no-edit HEAD | head -1
[main 44bc3ca] Revert "Speed up total"
git log --oneline -3
44bc3ca Revert "Speed up total"
ca46433 Speed up total
7418016 First version of the shop
head -2 app.py
def total(prices, tax=0.2):
    return round(sum(prices) * (1 + tax), 2)

Summary

Roll back first, fix later. Redeploy the previous tag, switch blue green back, or git revert. Next, turning features on and off without deploying.

Key takeaways
  • Redeploy the old tag
  • git revert
  • Practice rollbacks
Next up: Feature Flags — ship it switched off