Repository navigation
432 lines (376 loc) · 15.5 KB
/
Copy pathdeploy-production.yml
File metadata and controls
432 lines (376 loc) · 15.5 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
name: Deploy Orbit to Cloudflare
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: orbit-production
cancel-in-progress: true
jobs:
frontend:
runs-on: ubuntu-latest
timeout-minutes: 12
outputs:
scope: ${{ steps.scope.outputs.scope }}
steps:
- name: Checkout exact production candidate and history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Test the fail-safe classifier
run: npm run actions:scope:test
- name: Classify changed paths
id: scope
env:
BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == 'workflow_dispatch' || -z "$BEFORE_SHA" || "$BEFORE_SHA" =~ ^0+$ ]]; then
printf 'scope=full\n' >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only "$BEFORE_SHA" "$GITHUB_SHA" | node scripts/orbit-actions-scope.mjs
- name: Set up Node
if: ${{ steps.scope.outputs.scope != 'docs' }}
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
if: ${{ steps.scope.outputs.scope != 'docs' }}
run: npm ci
- name: Build and verify the production frontend once
if: ${{ steps.scope.outputs.scope != 'docs' }}
run: npm run verify:frontend:production
- name: Create the verified asset manifest
if: ${{ steps.scope.outputs.scope != 'docs' }}
run: |
test "$(find dist/client -type f -path '*/.*' ! -path 'dist/client/.assetsignore' -print -quit)" = ''
printf 'wrangler.json\n.dev.vars\n' \
| diff --unified - dist/client/.assetsignore
find dist/client -type f -print0 \
| sort -z \
| xargs -0 sha256sum > production-assets.sha256
sha256sum dist/worker-production-live/worker.js >> production-assets.sha256
sha256sum --check production-assets.sha256
- name: Upload verified production assets
if: ${{ steps.scope.outputs.scope != 'docs' }}
uses: actions/upload-artifact@v7
with:
name: orbit-production-assets-${{ github.sha }}
path: |
dist/client
dist/worker-production-live/worker.js
production-assets.sha256
if-no-files-found: error
include-hidden-files: true
retention-days: 1
backend-foundation:
runs-on: ubuntu-latest
timeout-minutes: 12
outputs:
scope: ${{ steps.scope.outputs.scope }}
steps:
- name: Checkout foundation candidate and history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify changed paths independently
id: scope
env:
BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == 'workflow_dispatch' || -z "$BEFORE_SHA" || "$BEFORE_SHA" =~ ^0+$ ]]; then
printf 'scope=full\n' >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only "$BEFORE_SHA" "$GITHUB_SHA" | node scripts/orbit-actions-scope.mjs
- name: Set up Node
if: ${{ steps.scope.outputs.scope == 'full' }}
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm ci
- name: Verify D1 foundation, authorization and reference clients
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm run test:d1:core:foundation && npm run orbit:test:clients
- name: Record frontend-only decision
if: ${{ steps.scope.outputs.scope != 'full' }}
run: echo 'No backend/security path changed; this validation slice is not required.'
backend-site:
runs-on: ubuntu-latest
timeout-minutes: 12
outputs:
scope: ${{ steps.scope.outputs.scope }}
steps:
- name: Checkout site-auth candidate and history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify changed paths independently
id: scope
env:
BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == 'workflow_dispatch' || -z "$BEFORE_SHA" || "$BEFORE_SHA" =~ ^0+$ ]]; then
printf 'scope=full\n' >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only "$BEFORE_SHA" "$GITHUB_SHA" | node scripts/orbit-actions-scope.mjs
- name: Set up Node
if: ${{ steps.scope.outputs.scope == 'full' }}
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm ci
- name: Verify site authorization and sign-in behavior
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm run test:d1:core:site
- name: Record frontend-only decision
if: ${{ steps.scope.outputs.scope != 'full' }}
run: echo 'No backend/security path changed; this validation slice is not required.'
backend-public:
runs-on: ubuntu-latest
timeout-minutes: 12
outputs:
scope: ${{ steps.scope.outputs.scope }}
steps:
- name: Checkout public-core candidate and history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify changed paths independently
id: scope
env:
BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == 'workflow_dispatch' || -z "$BEFORE_SHA" || "$BEFORE_SHA" =~ ^0+$ ]]; then
printf 'scope=full\n' >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only "$BEFORE_SHA" "$GITHUB_SHA" | node scripts/orbit-actions-scope.mjs
- name: Set up Node
if: ${{ steps.scope.outputs.scope == 'full' }}
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm ci
- name: Verify public repository and identity behavior
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm run test:d1:core:public
- name: Record frontend-only decision
if: ${{ steps.scope.outputs.scope != 'full' }}
run: echo 'No backend/security path changed; this validation slice is not required.'
backend-publication:
runs-on: ubuntu-latest
timeout-minutes: 12
outputs:
scope: ${{ steps.scope.outputs.scope }}
steps:
- name: Checkout publication candidate and history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify changed paths independently
id: scope
env:
BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == 'workflow_dispatch' || -z "$BEFORE_SHA" || "$BEFORE_SHA" =~ ^0+$ ]]; then
printf 'scope=full\n' >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only "$BEFORE_SHA" "$GITHUB_SHA" | node scripts/orbit-actions-scope.mjs
- name: Set up Node
if: ${{ steps.scope.outputs.scope == 'full' }}
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm ci
- name: Verify publication, backup, media and dashboard behavior
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm run test:d1:publication
- name: Record frontend-only publication decision
if: ${{ steps.scope.outputs.scope != 'full' }}
run: echo 'No backend/security path changed; publication validation is not required.'
backend-platform:
runs-on: ubuntu-latest
timeout-minutes: 12
outputs:
scope: ${{ steps.scope.outputs.scope }}
steps:
- name: Checkout platform candidate and history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify changed paths independently
id: scope
env:
BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == 'workflow_dispatch' || -z "$BEFORE_SHA" || "$BEFORE_SHA" =~ ^0+$ ]]; then
printf 'scope=full\n' >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only "$BEFORE_SHA" "$GITHUB_SHA" | node scripts/orbit-actions-scope.mjs
- name: Set up Node
if: ${{ steps.scope.outputs.scope == 'full' }}
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm ci
- name: Verify dashboard, media and platform behavior
if: ${{ steps.scope.outputs.scope == 'full' }}
run: npm run test:d1:platform
- name: Record frontend-only platform decision
if: ${{ steps.scope.outputs.scope != 'full' }}
run: echo 'No backend/security path changed; platform validation is not required.'
deploy:
needs:
- frontend
- backend-foundation
- backend-site
- backend-public
- backend-publication
- backend-platform
if: ${{ needs.frontend.result == 'success' && needs.backend-foundation.result == 'success' && needs.backend-site.result == 'success' && needs.backend-public.result == 'success' && needs.backend-publication.result == 'success' && needs.backend-platform.result == 'success' && needs.frontend.outputs.scope != 'docs' && needs.frontend.outputs.scope == needs.backend-foundation.outputs.scope && needs.frontend.outputs.scope == needs.backend-site.outputs.scope && needs.frontend.outputs.scope == needs.backend-public.outputs.scope && needs.frontend.outputs.scope == needs.backend-publication.outputs.scope && needs.frontend.outputs.scope == needs.backend-platform.outputs.scope }}
runs-on: ubuntu-latest
timeout-minutes: 8
environment:
name: production
url: https://orbit.sametbasbug.dev
steps:
- name: Checkout the verified commit
uses: actions/checkout@v7
- name: Set up Node
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install deployment dependencies
run: npm ci
- name: Download verified production assets
uses: actions/download-artifact@v8
with:
name: orbit-production-assets-${{ github.sha }}
path: .
- name: Verify artifact and commit identity
run: |
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
sha256sum --check production-assets.sha256
- name: Deploy the verified main artifact
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
ORBIT_LIVE_OAUTH_CLIENT_ID: ${{ secrets.ORBIT_LIVE_OAUTH_CLIENT_ID }}
ORBIT_LIVE_OAUTH_CLIENT_SECRET: ${{ secrets.ORBIT_LIVE_OAUTH_CLIENT_SECRET }}
ORBIT_MCP_SERVICE_SECRET_V1: ${{ secrets.ORBIT_MCP_SERVICE_SECRET_V1 }}
ORBIT_MCP_DELEGATION_PEPPER_V1: ${{ secrets.ORBIT_MCP_DELEGATION_PEPPER_V1 }}
ORBIT_OIDC_SIGNING_KEY_V1: ${{ secrets.ORBIT_OIDC_SIGNING_KEY_V1 }}
ORBIT_SITE_TOKEN_PEPPER_V1: ${{ secrets.ORBIT_SITE_TOKEN_PEPPER_V1 }}
run: |
if [[ -z "$ORBIT_LIVE_OAUTH_CLIENT_ID" || -z "$ORBIT_LIVE_OAUTH_CLIENT_SECRET" ]]; then
echo 'Live Google OAuth deployment secrets are missing.' >&2
exit 1
fi
if [[ -z "$ORBIT_MCP_SERVICE_SECRET_V1" || -z "$ORBIT_MCP_DELEGATION_PEPPER_V1" ]]; then
echo 'Orbit MCP production secrets are missing.' >&2
exit 1
fi
# Site giriş kapısının iki sırrı. Eksikse dağıtım burada duruyor,
# çalışma zamanında durmuyor: eksik bir imza anahtarının gerçek sonucu
# yalnızca o kapının kapalı olması, ve kapı bunu kendi başına 503 ile
# söylüyor. Bir kapının anahtarını kaybetmek evi yıkmamalı.
if [[ -z "$ORBIT_OIDC_SIGNING_KEY_V1" || -z "$ORBIT_SITE_TOKEN_PEPPER_V1" ]]; then
echo 'Orbit site sign-in production secrets are missing.' >&2
exit 1
fi
oauth_secrets_file="$(mktemp)"
trap 'rm -f "$oauth_secrets_file"' EXIT
chmod 600 "$oauth_secrets_file"
jq -n '{
GOOGLE_OAUTH_CLIENT_ID: env.ORBIT_LIVE_OAUTH_CLIENT_ID,
GOOGLE_OAUTH_CLIENT_SECRET: env.ORBIT_LIVE_OAUTH_CLIENT_SECRET,
ORBIT_MCP_SERVICE_SECRET_V1: env.ORBIT_MCP_SERVICE_SECRET_V1,
ORBIT_MCP_DELEGATION_PEPPER_V1: env.ORBIT_MCP_DELEGATION_PEPPER_V1,
ORBIT_OIDC_SIGNING_KEY_V1: env.ORBIT_OIDC_SIGNING_KEY_V1,
ORBIT_SITE_TOKEN_PEPPER_V1: env.ORBIT_SITE_TOKEN_PEPPER_V1
}' > "$oauth_secrets_file"
unset ORBIT_LIVE_OAUTH_CLIENT_ID ORBIT_LIVE_OAUTH_CLIENT_SECRET
unset ORBIT_MCP_SERVICE_SECRET_V1 ORBIT_MCP_DELEGATION_PEPPER_V1
unset ORBIT_OIDC_SIGNING_KEY_V1 ORBIT_SITE_TOKEN_PEPPER_V1
npx wrangler d1 migrations apply DB \
--remote \
--config wrangler.production.live.jsonc
short_sha="${GITHUB_SHA::12}"
npx wrangler deploy \
dist/worker-production-live/worker.js \
--no-bundle \
--config wrangler.production.live.jsonc \
--secrets-file "$oauth_secrets_file" \
--tag "main-${short_sha}" \
--message "Automatic production deploy from main ${short_sha}"
- name: Verify the live site
run: |
health="$(curl --fail --silent --show-error \
--retry 8 --retry-delay 3 --retry-all-errors \
https://orbit.sametbasbug.dev/healthz)"
HEALTH="$health" node -e '
const health = JSON.parse(process.env.HEALTH);
if (health.ok !== true || health.service !== "orbit-v6" || health.environment !== "production") {
throw new Error(`Unexpected health response: ${JSON.stringify(health)}`);
}
'
headers="$(mktemp)"
trap 'rm -f "$headers"' EXIT
curl --fail --silent --show-error \
--retry 8 --retry-delay 3 --retry-all-errors \
--dump-header "$headers" --output /dev/null \
https://orbit.sametbasbug.dev/
grep -qi '^cf-ray:' "$headers"
if grep -qi '^server: GitHub.com' "$headers"; then
echo 'Live Orbit unexpectedly resolved to GitHub Pages.' >&2
exit 1
fi
if grep -qi '^x-robots-tag:.*noindex' "$headers"; then
echo 'Live Orbit unexpectedly returned a noindex header.' >&2
exit 1
fi
- name: Verify the live agent contract with both reference clients
run: |
for attempt in {1..8}; do
if npm run contract:live; then
exit 0
fi
if [[ "$attempt" -lt 8 ]]; then
echo "Live contract has not converged yet; retrying in 3 seconds."
sleep 3
fi
done
exit 1