Manual Rollback
yaml
1name: Rollback
2
3on:
4 workflow_dispatch:
5 inputs:
6 version:
7 description: 'Version to rollback to'
8 required: true
9
10jobs:
11 rollback:
12 runs-on: ubuntu-latest
13 environment: production
14
15 steps:
16 - name: Rollback to version
17 run: |
18 heroku releases:rollback ${{ github.event.inputs.version }}
19 env:
20 HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}Automatic Rollback
yaml
1- name: Deploy
2 id: deploy
3 run: ./deploy.sh
4
5- name: Health check
6 id: health
7 run: |
8 sleep 30
9 curl -sf https://myapp.com/health || exit 1
10
11- name: Rollback on failure
12 if: failure() && steps.deploy.outcome == 'success'
13 run: |
14 echo "Deployment unhealthy, rolling back..."
15 heroku releases:rollbackBlue-Green Deployment
yaml
1- name: Deploy to green
2 run: ./deploy-green.sh
3
4- name: Test green environment
5 run: curl -sf https://green.myapp.com/health
6
7- name: Switch traffic
8 run: ./switch-to-green.sh
9
10- name: Rollback if needed
11 if: failure()
12 run: ./switch-to-blue.shDatabase Rollbacks
bash
1# Rollback last migration
2rails db:rollback
3
4# Rollback specific version
5rails db:migrate:down VERSION=20240101000000