Repository navigation
179 lines (159 loc) · 7.17 KB
/
Copy pathdocs-rollback.yml
File metadata and controls
179 lines (159 loc) · 7.17 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Docs Rollback
on:
workflow_dispatch:
inputs:
release_sha:
description: Commit from a previously verified release identity
required: true
type: string
tree_sha256:
description: Tree SHA-256 from the same verified release identity
required: true
type: string
permissions:
contents: read
concurrency:
group: docs-production
cancel-in-progress: false
env:
ARTIFACT_NAME: nextclaw-docs-rollback-${{ inputs.release_sha }}-${{ inputs.tree_sha256 }}-${{ github.run_id }}
RELEASE_COMMIT: ${{ inputs.release_sha }}
RELEASE_TREE: ${{ inputs.tree_sha256 }}
jobs:
prepare:
runs-on: ubuntu-latest
environment: docs-cn-production
permissions:
contents: read
id-token: write
outputs:
tree_sha256: ${{ steps.manifest.outputs.tree_sha256 }}
steps:
- name: Install pinned OSS CLI
run: |
mkdir -p "$RUNNER_TEMP/bin"
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
curl -fsSLo "$RUNNER_TEMP/ossutil.zip" \
https://gosspublic.alicdn.com/ossutil/v2/2.3.0/ossutil-2.3.0-linux-amd64.zip
echo "3ae4d9fc85a7a6e9f5654d1599766f1a3a42a3692870887b5ae9338d582ef65a $RUNNER_TEMP/ossutil.zip" | sha256sum -c -
unzip -q "$RUNNER_TEMP/ossutil.zip" -d "$RUNNER_TEMP"
install -m 0755 "$RUNNER_TEMP/ossutil-2.3.0-linux-amd64/ossutil" "$RUNNER_TEMP/bin/ossutil"
- name: Exchange GitHub identity for short-lived Alibaba credentials
uses: aliyun/configure-aliyun-credentials-action@1e5248c8d5d93a8781ac344a68e19a43341e79e6
with:
audience: sts.aliyuncs.com
oidc-provider-arn: ${{ vars.ALIYUN_DOCS_OIDC_PROVIDER_ARN }}
role-to-assume: ${{ vars.ALIYUN_DOCS_ROLE_ARN }}
role-session-expiration: 1800
role-session-name: docs-rollback-${{ github.run_id }}
- name: Download previously verified artifact without rebuilding
env:
BUCKET: ${{ vars.ALIYUN_DOCS_BUCKET }}
REGION: ${{ vars.ALIYUN_DOCS_REGION }}
run: |
export OSS_ACCESS_KEY_ID="$ALIBABA_CLOUD_ACCESS_KEY_ID"
export OSS_ACCESS_KEY_SECRET="$ALIBABA_CLOUD_ACCESS_KEY_SECRET"
export OSS_SESSION_TOKEN="$ALIBABA_CLOUD_SECURITY_TOKEN"
export OSS_REGION="$REGION"
ossutil sync "oss://$BUCKET/_releases/$RELEASE_COMMIT/$RELEASE_TREE/" docs-dist --region "$REGION" --mode StsToken --force
- name: Validate archived manifest
id: manifest
run: |
test "$(jq -r .commit docs-dist/release-manifest.json)" = "$RELEASE_COMMIT"
test "$(jq -r .treeSha256 docs-dist/release-manifest.json)" = "$RELEASE_TREE"
echo "tree_sha256=$(jq -r .treeSha256 docs-dist/release-manifest.json)" >> "$GITHUB_OUTPUT"
- name: Upload rollback artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.ARTIFACT_NAME }}
path: docs-dist
if-no-files-found: error
retention-days: 30
rollback-global:
needs: prepare
runs-on: ubuntu-latest
environment: production
steps:
- name: Download rollback artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.ARTIFACT_NAME }}
path: docs-dist
- name: Promote archived artifact to Cloudflare Pages
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "4.67.0"
command: >-
pages deploy docs-dist
--project-name=nextclaw-docs
--branch=master
--commit-hash=${{ env.RELEASE_COMMIT }}
rollback-domestic:
needs: prepare
runs-on: ubuntu-latest
environment: docs-cn-production
permissions:
contents: read
id-token: write
steps:
- name: Checkout infrastructure contract
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download rollback artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.ARTIFACT_NAME }}
path: docs-dist
- name: Install pinned cloud CLIs
run: |
mkdir -p "$RUNNER_TEMP/bin"
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
curl -fsSLo "$RUNNER_TEMP/ossutil.zip" \
https://gosspublic.alicdn.com/ossutil/v2/2.3.0/ossutil-2.3.0-linux-amd64.zip
echo "3ae4d9fc85a7a6e9f5654d1599766f1a3a42a3692870887b5ae9338d582ef65a $RUNNER_TEMP/ossutil.zip" | sha256sum -c -
unzip -q "$RUNNER_TEMP/ossutil.zip" -d "$RUNNER_TEMP"
install -m 0755 "$RUNNER_TEMP/ossutil-2.3.0-linux-amd64/ossutil" "$RUNNER_TEMP/bin/ossutil"
- name: Setup Alibaba Cloud CLI
uses: aliyun/setup-aliyun-cli-action@09a5f86915bb556e27bf050e9a5e339aeb073df5
with:
version: "3.4.6"
- name: Exchange GitHub identity for short-lived Alibaba credentials
uses: aliyun/configure-aliyun-credentials-action@1e5248c8d5d93a8781ac344a68e19a43341e79e6
with:
audience: sts.aliyuncs.com
oidc-provider-arn: ${{ vars.ALIYUN_DOCS_OIDC_PROVIDER_ARN }}
role-to-assume: ${{ vars.ALIYUN_DOCS_ROLE_ARN }}
role-session-expiration: 1800
role-session-name: docs-rollback-${{ github.run_id }}-${{ github.run_attempt }}
- name: Promote archived artifact to domestic production
env:
BUCKET: ${{ vars.ALIYUN_DOCS_BUCKET }}
REGION: ${{ vars.ALIYUN_DOCS_REGION }}
run: |
export OSS_ACCESS_KEY_ID="$ALIBABA_CLOUD_ACCESS_KEY_ID"
export OSS_ACCESS_KEY_SECRET="$ALIBABA_CLOUD_ACCESS_KEY_SECRET"
export OSS_SESSION_TOKEN="$ALIBABA_CLOUD_SECURITY_TOKEN"
export OSS_REGION="$REGION"
ossutil sync docs-dist "oss://$BUCKET/" --region "$REGION" --mode StsToken --force
ossutil set-props "oss://$BUCKET/release-manifest.json" --region "$REGION" --mode StsToken --metadata-directive replace --content-type application/json --cache-control no-store --force
- name: Refresh domestic CDN
env:
CDN_DOMAIN: ${{ vars.ALIYUN_DOCS_CDN_DOMAIN }}
REGION: ${{ vars.ALIYUN_DOCS_REGION }}
run: |
refresh_paths=$(node scripts/deploy/docs/create-cdn-refresh-paths.mjs --dist docs-dist --domain "$CDN_DOMAIN")
aliyun cdn RefreshObjectCaches --region "$REGION" --ObjectPath "$refresh_paths" --ObjectType File
verify:
needs: [prepare, rollback-global, rollback-domestic]
runs-on: ubuntu-latest
steps:
- name: Checkout verifier
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Verify rollback artifact on both production domains
env:
NEXTCLAW_DOCS_CN_CNAME: ${{ vars.ALIYUN_DOCS_CDN_CNAME }}
run: >-
node scripts/deploy/docs/verify-docs-deployment.mjs
--expected-commit "${{ env.RELEASE_COMMIT }}"
--expected-tree "${{ needs.prepare.outputs.tree_sha256 }}"