Revert production to the previous release tag and create a tracking issue.
Revert main to a previous release tag when the current production deploy is
broken. Creates a tracking issue for the incident.
git fetch origin main --tags
List recent tags:
git tag --sort=-version:refname | head -10
If $ARGUMENTS is provided, use it as the target tag. Otherwise, default to
the second-most-recent tag (the one before the current release):
CURRENT_TAG=$(git describe --tags --abbrev=0 origin/main)
PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p')
Confirm with the user: "Roll back from $CURRENT_TAG to $PREVIOUS_TAG?"
git checkout main
git pull origin main
git revert --no-commit "$PREVIOUS_TAG"..HEAD
git commit -m "revert: rollback to $PREVIOUS_TAG"
git push origin main
This reverts all commits between the target tag and HEAD on main, keeping full git history (no force push).
gh issue create \
--title "Rollback: $CURRENT_TAG → $PREVIOUS_TAG" \
--body "## Rollback Summary
**From:** $CURRENT_TAG
**To:** $PREVIOUS_TAG
**Date:** $(date -u +%Y-%m-%dT%H:%M:%SZ)
**Trigger:** [describe what went wrong]
## Reverted changes
$(git log $PREVIOUS_TAG..$CURRENT_TAG --oneline)
## Action items
- [ ] Investigate root cause
- [ ] Fix the issue on dev
- [ ] Re-release with fix
"
Tell the user:
$PREVIOUS_TAGmain, so no history was lost