-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (115 loc) · 4.07 KB
/
Copy pathcascade-rollback.yaml
File metadata and controls
122 lines (115 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# AUTO-GENERATED by cascade - DO NOT EDIT MANUALLY
# Regenerate with: cascade generate-workflow --config .github/manifest.yaml
#
# Manual rollback: re-deploy a prior version or SHA to an environment.
#
# A read-only preflight resolves the target (from live state, the
# deploy-history ring, or manifest history), the deploy stage re-runs the
# configured deploy callbacks keyed on the resolved SHA, and finalize writes
# the rolled-back state back to trunk, marking the environment diverged until
# a forward promotion rejoins it.
name: Rollback
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to roll back'
required: true
type: choice
options:
- prod
target:
description: 'Prior version or SHA (optional; defaults to the previous version)'
required: false
type: string
default: ''
deployable:
description: 'Limit rollback to one deployable (optional)'
required: false
type: string
default: ''
dry_run:
description: 'Resolve and print without deploying'
required: false
type: boolean
default: false
permissions:
contents: read
concurrency:
group: "${{ github.workflow }}"
cancel-in-progress: false
jobs:
preflight:
name: Pre-flight Check
runs-on: ubuntu-latest
outputs:
target_env: ${{ steps.preflight.outputs.target_env }}
target_sha: ${{ steps.preflight.outputs.target_sha }}
target_version: ${{ steps.preflight.outputs.target_version }}
target_source: ${{ steps.preflight.outputs.target_source }}
can_proceed: ${{ steps.preflight.outputs.can_proceed }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup CLI
uses: stablekernel/cascade/.github/actions/setup-cli@v0.16.6
with:
token: ${{ secrets.CASCADE_STATE_TOKEN }}
version: v0.16.6
- name: Resolve Target
id: preflight
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
TARGET: ${{ github.event.inputs.target }}
DEPLOYABLE: ${{ github.event.inputs.deployable }}
run: |
cascade rollback preflight \
--config .github/manifest.yaml \
--env "$ENVIRONMENT" \
--to "$TARGET" \
--deployable "$DEPLOYABLE" \
--gha-output
- name: Fail if Cannot Proceed
if: steps.preflight.outputs.can_proceed == 'false'
run: exit 1
- name: Report Resolved Source
run: echo "rollback resolved from ${{ steps.preflight.outputs.target_source }}"
deploy-app:
name: Deploy app
needs: [preflight]
if: ${{ github.event.inputs.dry_run != 'true' && (github.event.inputs.deployable == '' || github.event.inputs.deployable == 'app') }}
uses: ./.github/workflows/deploy-app.yaml
with:
environment: ${{ needs.preflight.outputs.target_env }}
sha: ${{ needs.preflight.outputs.target_sha }}
finalize:
name: Finalize
needs: [preflight, deploy-app]
if: always() && needs.preflight.result == 'success' && github.event.inputs.dry_run != 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup CLI
uses: stablekernel/cascade/.github/actions/setup-cli@v0.16.6
with:
token: ${{ secrets.CASCADE_STATE_TOKEN }}
version: v0.16.6
- name: Finalize Rollback
env:
GH_TOKEN: ${{ secrets.CASCADE_STATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CASCADE_STATE_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
DEPLOYABLE: ${{ github.event.inputs.deployable }}
DEPLOY_RESULT_APP: ${{ needs.deploy-app.result }}
run: |
cascade rollback finalize \
--config .github/manifest.yaml \
--env "${{ needs.preflight.outputs.target_env }}" \
--to "${{ needs.preflight.outputs.target_sha }}" \
--deployable "$DEPLOYABLE" \
--commit-push