-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (85 loc) · 3.63 KB
/
Copy pathrollback-docs.yml
File metadata and controls
94 lines (85 loc) · 3.63 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
name: Rollback Docs
# Manual recovery tool for a bad production docs deploy.
#
# Why this exists rather than "just revert the commit": Cloudflare rejects an
# oversized upload at VERSION CREATION, so a failed deploy does not roll
# anything back — the previously accepted version simply keeps serving. The
# corollary bit us on 2026-09-04: once a bad version has been accepted,
# reverting the offending commit only rebuilds a bundle that gets rejected
# again, which leaves the bad version live. Recovery has to happen on
# Cloudflare's side, against a version id.
#
# Usage:
# 1. Dispatch with version_id EMPTY -> lists versions, changes nothing.
# 2. Read the list, pick the last known-good version id.
# 3. Dispatch again with that id -> rolls back to it.
on:
workflow_dispatch:
inputs:
version_id:
description: 'Worker version id to roll back to. LEAVE BLANK to only list versions and change nothing.'
required: false
type: string
reason:
description: 'Why this rollback is happening (recorded as the rollback message).'
required: false
type: string
jobs:
rollback:
runs-on: ubuntu-latest
# Same environment as deploy-docs.yml: it holds the credentials, and any
# required-reviewer protection added there gates this workflow too.
environment:
name: cloudflare-docs
url: https://docs-objectos.objectstack.workers.dev
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
# Always runs. A rollback target should come from a reading, not a guess.
- name: List Worker versions
working-directory: apps/docs
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: pnpm exec wrangler versions list --name docs-objectos
- name: Show current deployment
working-directory: apps/docs
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: pnpm exec wrangler deployments status --name docs-objectos || true
- name: Roll back to the requested version
if: ${{ inputs.version_id != '' }}
working-directory: apps/docs
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
VERSION_ID: ${{ inputs.version_id }}
REASON: ${{ inputs.reason }}
shell: bash
run: |
set -euo pipefail
# Validate before use: this value reaches a command line, and a
# malformed id should fail loudly here rather than somewhere odd.
if ! printf '%s' "$VERSION_ID" | grep -Eq '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'; then
echo "::error::version_id is not a UUID: $VERSION_ID"
exit 1
fi
pnpm exec wrangler rollback "$VERSION_ID" \
--name docs-objectos \
--message "${REASON:-manual rollback via rollback-docs.yml}" \
--yes
- name: Confirm what is serving now
if: ${{ inputs.version_id != '' }}
working-directory: apps/docs
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: pnpm exec wrangler deployments status --name docs-objectos