{{ message }}
Repository navigation
998 lines (977 loc) · 52.7 KB
/
Copy pathfetch-docs.yml
File metadata and controls
998 lines (977 loc) · 52.7 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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
name: fetch lark docs
on:
workflow_dispatch:
inputs:
group:
description: "Content group(s) to publish: all, guides, or a comma-separated subset (e.g. python,java). Valid groups: all, guides, python, java, node, go, cli, rest, cpp"
type: string
default: all
artifact_retention_days:
description: Artifact retention in days
type: number
default: 3
target_branch:
description: Existing branch to publish to
type: string
default: dev
publish:
description: Publish produced English artifacts
type: boolean
default: true
media_upload_mode:
description: Object-storage behavior for controlled artifact-only Guides validation
type: choice
options: [write, skip]
default: write
run_translations:
description: Dispatch the downstream translation workflow
type: boolean
default: false
tooling_ref:
description: Tooling ref override; exact SHA allowed for controlled dev publication
type: string
default: master
source_ref:
description: "English content baseline branch, tag, or exact SHA"
type: string
default: dev
force_full_fetch:
description: "Force a full Guides source fetch that ignores incremental planning (manual dispatch only; applies to en and zh-CN Guides)"
type: boolean
default: false
schedule:
- cron: "0 2,10,18 * * *"
permissions:
contents: read
actions: read
env:
FEISHU_NOTIFICATIONS_DISABLED: ${{ vars.FEISHU_NOTIFICATIONS_DISABLED || '' }}
concurrency:
group: docs-production-dev
queue: max
jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: write
outputs:
tooling_sha: ${{ steps.refs.outputs.tooling_sha }}
source_sha: ${{ steps.refs.outputs.source_sha }}
master_sha: ${{ steps.refs.outputs.master_sha }}
dev_baseline_sha: ${{ steps.refs.outputs.dev_baseline_sha }}
initial_target_sha: ${{ steps.refs.outputs.initial_target_sha }}
effective_target_sha: ${{ steps.verify_target_inventory.outputs.effective_target_sha || steps.refs.outputs.initial_target_sha }}
target_branch: ${{ steps.refs.outputs.target_branch }}
publish: ${{ steps.refs.outputs.publish }}
run_translations: ${{ steps.refs.outputs.run_translations }}
media_upload_mode: ${{ steps.refs.outputs.media_upload_mode }}
force_full_fetch: ${{ steps.refs.outputs.force_full_fetch }}
selected_group: ${{ steps.refs.outputs.selected_group }}
has_translation_units: ${{ steps.translation_units.outputs.has_translation_units }}
retention_days: ${{ steps.refs.outputs.retention_days }}
selected_sdk_groups: ${{ steps.sdk_groups.outputs.groups }}
selected_sdk_count: ${{ steps.sdk_groups.outputs.count }}
publication_selection_artifact_name: ${{ steps.publication_selection.outputs.artifact_name }}
publication_selection_sha256: ${{ steps.publication_selection.outputs.selection_sha256 }}
card_id: ${{ steps.card.outputs.card_id }}
card_started_at: ${{ steps.card.outputs.card_started_at }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
fetch-depth: 1
- id: refs
name: Resolve immutable refs and selection
env:
SELECTED_GROUP: ${{ github.event.inputs.group || 'all' }}
RETENTION_DAYS: ${{ github.event.inputs.artifact_retention_days || '3' }}
TARGET_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || 'dev' }}
PUBLISH: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish == 'true' }}
RUN_TRANSLATIONS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.run_translations == 'true' }}
MEDIA_UPLOAD_MODE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.media_upload_mode || 'write' }}
TOOLING_REF: ${{ github.event.inputs.tooling_ref || 'master' }}
SOURCE_REF: ${{ github.event.inputs.source_ref || 'dev' }}
FORCE_FULL_FETCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.force_full_fetch == 'true' }}
run: |
set -euo pipefail
if [[ "$TARGET_BRANCH" == -* || "$TARGET_BRANCH" == *:* || "$TARGET_BRANCH" == *$'\n'* || "$TARGET_BRANCH" == *$'\r'* ]]; then
echo 'target_branch contains forbidden characters' >&2
exit 2
fi
git check-ref-format --branch "$TARGET_BRANCH"
tooling_ref="$TOOLING_REF"
if [[ "$PUBLISH" == true && "$TARGET_BRANCH" == dev && ! "$tooling_ref" =~ ^[0-9a-f]{40}$ ]]; then
tooling_ref=master
fi
if [[ "$tooling_ref" =~ ^[0-9a-f]{40}$ ]]; then
git fetch --no-tags origin "$tooling_ref"
master_sha=$(git rev-parse FETCH_HEAD)
else
if [[ "$tooling_ref" == -* || "$tooling_ref" == *:* || "$tooling_ref" == *$'\n'* || "$tooling_ref" == *$'\r'* ]]; then
echo 'tooling_ref contains forbidden characters' >&2
exit 2
fi
git check-ref-format --branch "$tooling_ref"
git fetch --no-tags origin "refs/heads/$tooling_ref:refs/remotes/origin/$tooling_ref"
master_sha=$(git rev-parse "refs/remotes/origin/$tooling_ref")
fi
git cat-file -e "$master_sha^{commit}"
node -e 'require("./scripts/docs-workflow/resolve-docs-refs").assertSafeGitRef(process.env.SOURCE_REF)'
git fetch --no-tags origin "$SOURCE_REF"
source_sha=$(git rev-parse FETCH_HEAD)
git fetch --no-tags origin "+refs/heads/$TARGET_BRANCH:refs/remotes/origin/$TARGET_BRANCH"
initial_target_sha=$(git rev-parse "refs/remotes/origin/$TARGET_BRANCH^{commit}")
tooling_sha=$master_sha
dev_baseline_sha=$source_sha
[[ "$tooling_sha" =~ ^[0-9a-f]{40}$ && "$source_sha" =~ ^[0-9a-f]{40}$ && "$initial_target_sha" =~ ^[0-9a-f]{40}$ ]]
case "$SELECTED_GROUP" in all|guides|python|java|node|go|cli|rest|cpp|*,*) ;; *) exit 2 ;; esac
case "$MEDIA_UPLOAD_MODE" in write|skip) ;; *) exit 2 ;; esac
if [[ "$MEDIA_UPLOAD_MODE" == skip ]]; then
[[ "$PUBLISH" == false && "$RUN_TRANSLATIONS" == false && "$SELECTED_GROUP" == guides ]] || {
echo 'media_upload_mode=skip is restricted to artifact-only Guides validation' >&2
exit 2
}
fi
[[ "$RETENTION_DAYS" =~ ^[1-9][0-9]*$ ]]
git checkout --detach "$master_sha"
card_parts=("Produce")
if [[ "$PUBLISH" == true ]]; then card_parts+=("Publish" "Verify"); fi
[[ "$RUN_TRANSLATIONS" == true ]] && card_parts+=("Handoff")
card_stages=$(IFS=,; echo "${card_parts[*]}")
printf 'tooling_sha=%s\nsource_sha=%s\nmaster_sha=%s\ndev_baseline_sha=%s\ninitial_target_sha=%s\ntarget_branch=%s\npublish=%s\nrun_translations=%s\nmedia_upload_mode=%s\nselected_group=%s\nretention_days=%s\ncard_stages=%s\nforce_full_fetch=%s\n' "$tooling_sha" "$source_sha" "$master_sha" "$dev_baseline_sha" "$initial_target_sha" "$TARGET_BRANCH" "$PUBLISH" "$RUN_TRANSLATIONS" "$MEDIA_UPLOAD_MODE" "$SELECTED_GROUP" "$RETENTION_DAYS" "$card_stages" "$FORCE_FULL_FETCH" >> "$GITHUB_OUTPUT"
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- id: sdk_groups
name: Compute selected SDK reference producer matrix
env:
SELECTED_GROUP: ${{ steps.refs.outputs.selected_group }}
run: |
echo "groups=$(node scripts/docs-workflow/print-workflow-groups.js --selected-sdk-groups-json "$SELECTED_GROUP")" >> "$GITHUB_OUTPUT"
echo "count=$(node scripts/docs-workflow/print-workflow-groups.js --selected-sdk-group-count "$SELECTED_GROUP")" >> "$GITHUB_OUTPUT"
- name: Validate selected publication groups
env:
SELECTED_GROUP: ${{ steps.refs.outputs.selected_group }}
run: node scripts/docs-workflow/print-workflow-groups.js --validate-groups "$SELECTED_GROUP"
- id: translation_units
name: Detect whether the selected groups yield translation units
env:
SELECTED_GROUP: ${{ steps.refs.outputs.selected_group }}
run: echo "has_translation_units=$(node scripts/docs-workflow/print-workflow-groups.js --has-translation-units "$SELECTED_GROUP")" >> "$GITHUB_OUTPUT"
- name: Verify translation publication readiness
run: node --test scripts/build/write-provenance.test.mjs scripts/doc-publish-bot/manualConfig.test.js scripts/docs-workflow/content-groups.test.js scripts/docs-workflow/fetch-reference-reconciliation.test.js scripts/docs-workflow/guides-cache-generation-lifecycle.test.js scripts/docs-workflow/guides-render-readiness.test.js scripts/docs-workflow/prepare-content-group-workspace.test.js scripts/docs-workflow/source-publication-barrier.test.js scripts/restore-generated-state.test.js scripts/validate-workflow-policy.test.js
- id: verify_target_inventory
name: Verify immutable target localization inventory
if: ${{ steps.refs.outputs.publish == 'true' }}
env:
INITIAL_TARGET_SHA: ${{ steps.refs.outputs.initial_target_sha }}
TOOLING_SHA: ${{ steps.refs.outputs.tooling_sha }}
TARGET_BRANCH: ${{ steps.refs.outputs.target_branch }}
run: |
set -euo pipefail
git fetch --no-tags origin "$INITIAL_TARGET_SHA"
bash scripts/restore-generated-state.sh --exact --ref "$INITIAL_TARGET_SHA"
if pnpm check:localization-input-inventory; then
# Inventory is already current: the immutable selection target is the
# pre-repair tip and the repair step never advanced dev.
echo "effective_target_sha=$INITIAL_TARGET_SHA" >> "$GITHUB_OUTPUT"
exit 0
fi
echo '::warning::immutable target localization inventory is stale; repairing Fetch Reference derived state before retrying'
node scripts/docs-workflow/repair-fetch-dev.js repair \
--repository-root "$GITHUB_WORKSPACE" \
--runner-temp "$RUNNER_TEMP" \
--target-branch "$TARGET_BRANCH" \
--remote origin
repaired_target_sha=$(git rev-parse "refs/remotes/origin/$TARGET_BRANCH^{commit}")
[[ "$repaired_target_sha" =~ ^[0-9a-f]{40}$ ]]
git fetch --no-tags origin "$repaired_target_sha"
bash scripts/restore-generated-state.sh --exact --ref "$repaired_target_sha"
pnpm check:localization-input-inventory
# Self-heal advanced dev past the pre-repair tip; every downstream
# immutable binding (publication selection and reconciliation preflight)
# must pin the repaired SHA, not the stale initial_target_sha.
echo "effective_target_sha=$repaired_target_sha" >> "$GITHUB_OUTPUT"
- id: publication_selection
name: Create immutable Fetch publication selection
env:
TOOLING_SHA: ${{ steps.refs.outputs.master_sha }}
TARGET_BRANCH: ${{ steps.refs.outputs.target_branch }}
# The self-heal repair advances dev past the pre-repair tip; the
# immutable selection must pin the repaired tip so publication and
# reconciliation preflight agree on the same target identity.
INITIAL_TARGET_SHA: ${{ steps.verify_target_inventory.outputs.effective_target_sha || steps.refs.outputs.initial_target_sha }}
# SOURCE_BASELINE_SHA is the source-content provenance watermark (the
# commit translation producers regenerate zh content from). Repair only
# refreshes dev-owned derived state (inventory + reference
# sidebars/manifests) and never rewrites source content, so the
# pre-repair source baseline remains the correct watermark even when
# source_ref == target branch.
SOURCE_BASELINE_SHA: ${{ steps.refs.outputs.dev_baseline_sha }}
SELECTED_GROUP: ${{ steps.refs.outputs.selected_group }}
PUBLISH: ${{ steps.refs.outputs.publish }}
RUN_TRANSLATIONS: ${{ steps.refs.outputs.run_translations }}
run: |
set -euo pipefail
selection_dir="$RUNNER_TEMP/publication-selection"
selection_file="$selection_dir/publication-selection.json"
artifact_name="publication-selection-fetch-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
mkdir -p "$selection_dir"
node scripts/docs-workflow/fetch-publication-selection.js selection --output "$selection_file"
node scripts/docs-workflow/publication-contracts.js validate-selection "$selection_file"
selection_sha256=$(node -e 'const fs=require("node:fs");process.stdout.write(JSON.parse(fs.readFileSync(process.argv[1],"utf8")).selectionSha256)' "$selection_file")
printf 'artifact_name=%s\nselection_sha256=%s\n' "$artifact_name" "$selection_sha256" >> "$GITHUB_OUTPUT"
- name: Upload immutable Fetch publication selection
uses: actions/upload-artifact@v6
with:
name: publication-selection-fetch-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/publication-selection/publication-selection.json
if-no-files-found: error
retention-days: ${{ fromJSON(steps.refs.outputs.retention_days) }}
- id: card
name: Create progress card
continue-on-error: true
run: pnpm docs-tooling report-card create --title "$CARD_TITLE" --stages "$CARD_STAGES" --target-branch "$TARGET_BRANCH"
env:
CARD_STAGES: ${{ steps.refs.outputs.card_stages }}
CARD_TITLE: Zilliz Cloud Docs Build
TARGET_BRANCH: ${{ steps.refs.outputs.target_branch }}
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
FEISHU_HOST: ${{ vars.FEISHU_HOST }}
monitor_docs_progress:
needs: [prepare]
if: ${{ needs.prepare.outputs.card_id != '' }}
uses: ./.github/workflows/_monitor-docs-progress.yml
with:
master_sha: ${{ needs.prepare.outputs.master_sha }}
card_id: ${{ needs.prepare.outputs.card_id }}
card_started_at: ${{ needs.prepare.outputs.card_started_at }}
target_branch: ${{ needs.prepare.outputs.target_branch }}
selected_group: ${{ needs.prepare.outputs.selected_group }}
publish_enabled: ${{ needs.prepare.outputs.publish == 'true' }}
run_translations: ${{ needs.prepare.outputs.run_translations == 'true' }}
publication_run_attempt: ${{ fromJSON(github.run_attempt) }}
publication_selection_sha256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
produce_guides_sources:
needs: prepare
if: ${{ needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides') }}
uses: ./.github/workflows/_fetch-guides-sources.yml
with:
site: en
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
media_upload_mode: ${{ needs.prepare.outputs.media_upload_mode }}
force_full_fetch: ${{ needs.prepare.outputs.force_full_fetch == 'true' }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
SPACE_ID: ${{ secrets.SPACE_ID }}
FIGMA_API_KEY: ${{ secrets.FIGMA_API_KEY }}
MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
render_guides_tables:
name: render_guides_tables / ${{ matrix.target_name }} / ${{ matrix.table_name }}
needs: [prepare, produce_guides_sources]
if: ${{ needs.produce_guides_sources.outputs.status == 'artifact_ready' && needs.produce_guides_sources.outputs.table_count != '0' }}
strategy:
fail-fast: false
max-parallel: 4
matrix: ${{ fromJSON(needs.produce_guides_sources.outputs.table_matrix) }}
uses: ./.github/workflows/_render-guides-table.yml
with:
site: en
table_id: ${{ matrix.table_id }}
table_name: ${{ matrix.table_name }}
table_slug: ${{ matrix.table_slug }}
target: ${{ matrix.target }}
target_name: ${{ matrix.target_name }}
cleanup: ${{ matrix.cleanup }}
source_artifact_name: ${{ needs.produce_guides_sources.outputs.artifact_name }}
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
produce_guides:
permissions:
actions: write
contents: read
needs: [prepare, produce_guides_sources, render_guides_tables]
if: ${{ always() && (needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides')) && needs.produce_guides_sources.outputs.status == 'artifact_ready' && (needs.render_guides_tables.result == 'success' || needs.render_guides_tables.result == 'skipped') }}
uses: ./.github/workflows/_assemble-guides.yml
with:
site: en
source_artifact_name: ${{ needs.produce_guides_sources.outputs.artifact_name || 'unavailable' }}
table_matrix: ${{ needs.produce_guides_sources.outputs.table_matrix || '{"include":[]}' }}
table_count: ${{ needs.produce_guides_sources.outputs.table_count || '0' }}
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
target_branch: ${{ needs.prepare.outputs.target_branch }}
publication_selection_artifact_name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
publication_selection_sha256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
publication_unit_key: source/guides-en
cache_version: ${{ needs.produce_guides_sources.outputs.cache_version }}
cache_save_required: ${{ needs.produce_guides_sources.outputs.cache_save_required }}
assembly_decision_sha256: ${{ needs.produce_guides_sources.outputs.assembly_decision_sha256 }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
produce_zh_guides_sources:
needs: prepare
if: ${{ needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides') }}
uses: ./.github/workflows/_fetch-guides-sources.yml
with:
site: zh-CN
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
media_upload_mode: ${{ needs.prepare.outputs.media_upload_mode }}
force_full_fetch: ${{ needs.prepare.outputs.force_full_fetch == 'true' }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
SPACE_ID: ${{ secrets.SPACE_ID }}
FIGMA_API_KEY: ${{ secrets.FIGMA_API_KEY }}
MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }}
OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
render_zh_guides_tables:
name: render_zh_guides_tables / ${{ matrix.target_name }} / ${{ matrix.table_name }}
needs: [prepare, produce_zh_guides_sources]
if: ${{ needs.produce_zh_guides_sources.outputs.status == 'artifact_ready' && needs.produce_zh_guides_sources.outputs.table_count != '0' }}
strategy:
fail-fast: false
max-parallel: 4
matrix: ${{ fromJSON(needs.produce_zh_guides_sources.outputs.table_matrix) }}
uses: ./.github/workflows/_render-guides-table.yml
with:
site: zh-CN
table_id: ${{ matrix.table_id }}
table_name: ${{ matrix.table_name }}
table_slug: ${{ matrix.table_slug }}
target: ${{ matrix.target }}
target_name: ${{ matrix.target_name }}
cleanup: ${{ matrix.cleanup }}
source_artifact_name: ${{ needs.produce_zh_guides_sources.outputs.artifact_name }}
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
produce_zh_guides:
permissions:
actions: write
contents: read
needs: [prepare, produce_zh_guides_sources, render_zh_guides_tables]
if: ${{ always() && (needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides')) && needs.produce_zh_guides_sources.outputs.status == 'artifact_ready' && (needs.render_zh_guides_tables.result == 'success' || needs.render_zh_guides_tables.result == 'skipped') }}
uses: ./.github/workflows/_assemble-guides.yml
with:
site: zh-CN
source_artifact_name: ${{ needs.produce_zh_guides_sources.outputs.artifact_name || 'unavailable' }}
table_matrix: ${{ needs.produce_zh_guides_sources.outputs.table_matrix || '{"include":[]}' }}
table_count: ${{ needs.produce_zh_guides_sources.outputs.table_count || '0' }}
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
target_branch: ${{ needs.prepare.outputs.target_branch }}
publication_selection_artifact_name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
publication_selection_sha256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
publication_unit_key: source/guides-zh-CN
cache_version: ${{ needs.produce_zh_guides_sources.outputs.cache_version }}
cache_save_required: ${{ needs.produce_zh_guides_sources.outputs.cache_save_required }}
assembly_decision_sha256: ${{ needs.produce_zh_guides_sources.outputs.assembly_decision_sha256 }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
produce_sdk_reference:
needs: prepare
# Job-level if runs before strategy evaluation, so a Guides-only selection
# skips this matrix job instead of failing on an empty 'group' vector.
if: ${{ needs.prepare.outputs.selected_sdk_count != '0' }}
name: produce_${{ matrix.group }}
strategy:
fail-fast: false
matrix:
group: ${{ fromJSON(needs.prepare.outputs.selected_sdk_groups) }}
uses: ./.github/workflows/_fetch-content-group.yml
with:
site: en
group: ${{ matrix.group }}
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
target_branch: ${{ needs.prepare.outputs.target_branch }}
publication_selection_artifact_name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
publication_selection_sha256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
publication_unit_key: source/${{ matrix.group }}
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
SPACE_ID: ${{ secrets.SPACE_ID }}
FIGMA_API_KEY: ${{ secrets.FIGMA_API_KEY }}
MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
publish_rest_zh-CN:
needs: prepare
name: publish_rest_zh-CN
if: ${{ needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'rest') }}
uses: ./.github/workflows/_fetch-content-group.yml
with:
site: zh-CN
group: rest
master_sha: ${{ needs.prepare.outputs.master_sha }}
dev_baseline_sha: ${{ needs.prepare.outputs.dev_baseline_sha }}
target_branch: ${{ needs.prepare.outputs.target_branch }}
publication_selection_artifact_name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
publication_selection_sha256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
publication_unit_key: source/rest-zh-CN
artifact_retention_days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
SPACE_ID: ${{ secrets.SPACE_ID }}
FIGMA_API_KEY: ${{ secrets.FIGMA_API_KEY }}
MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
reconciliation_preflight:
needs: [prepare, produce_guides, produce_zh_guides, produce_sdk_reference, publish_rest_zh-CN]
if: ${{ always() && needs.prepare.outputs.publish == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
actions: read
contents: read
outputs:
plans_artifact_name: ${{ steps.upload_plans.outputs.artifact_name }}
status: ${{ steps.status.outputs.status }}
env:
RUN_TRANSLATIONS: ${{ needs.prepare.outputs.run_translations }}
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}', fetch-depth: 0 }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- id: validate_producers
name: Validate selected reconciliation producers
if: ${{ needs.prepare.outputs.run_translations == 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: node scripts/docs-workflow/validate-reconciliation-producers.js "$RUNNER_TEMP/publication-selection/publication-selection.json"
- name: Download required source checkpoint artifacts
if: ${{ needs.prepare.outputs.run_translations == 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
selection="$RUNNER_TEMP/publication-selection/publication-selection.json"
mkdir -p "$RUNNER_TEMP/reconciliation-checkpoints"
node - "$selection" "$(node scripts/docs-workflow/print-workflow-groups.js --groups-json)" <<'NODE' > "$RUNNER_TEMP/reconciliation-artifacts.txt"
const fs = require('node:fs')
const selection = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'))
const needed = new Set(JSON.parse(process.argv[3]))
for (const unit of selection.units) {
if (unit.site !== 'en' || !needed.has(unit.translationSourceGroup)) continue
const token = unit.unitKey.replaceAll('/', '-')
process.stdout.write(`${token} ${unit.artifacts.checkpoint}\n`)
}
NODE
while IFS=' ' read -r unit_token artifact_name; do
[[ "$unit_token" =~ ^source-[A-Za-z0-9_-]+$ ]]
gh run download -n "$artifact_name" -D "$RUNNER_TEMP/reconciliation-checkpoints/$unit_token"
done < "$RUNNER_TEMP/reconciliation-artifacts.txt"
- id: preflight
name: Validate reconciliation plans before source publication
if: ${{ needs.prepare.outputs.run_translations == 'true' }}
env:
TARGET_BASELINE_SHA: ${{ needs.prepare.outputs.effective_target_sha }}
run: |
set -euo pipefail
selection="$RUNNER_TEMP/publication-selection/publication-selection.json"
node scripts/docs-workflow/fetch-reconciliation-preflight.js preflight \
--selection "$selection" \
--checkpoint-root "$RUNNER_TEMP/reconciliation-checkpoints" \
--repository "$GITHUB_WORKSPACE" \
--runner-temp "$RUNNER_TEMP" \
--target-baseline-sha "$TARGET_BASELINE_SHA" \
--output "$RUNNER_TEMP/reconciliation-plans"
- id: status
name: Finalize reconciliation preflight status
if: ${{ always() }}
env:
PREFLIGHT_OUTCOME: ${{ steps.preflight.outcome }}
PRODUCERS_OUTCOME: ${{ steps.validate_producers.outcome }}
run: |
set -euo pipefail
if [[ "$RUN_TRANSLATIONS" == false ]]; then
echo 'status=approved' >> "$GITHUB_OUTPUT"
elif [[ "$PRODUCERS_OUTCOME" == success && "$PREFLIGHT_OUTCOME" == success ]]; then
echo 'status=approved' >> "$GITHUB_OUTPUT"
else
echo 'status=failed' >> "$GITHUB_OUTPUT"
exit 1
fi
- id: upload_plans
name: Upload reconciliation preflight evidence
if: ${{ always() && steps.preflight.outcome == 'success' }}
run: echo "artifact_name=fetch-reconciliation-plans-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
- name: Upload reconciliation plan evidence
if: ${{ always() && steps.preflight.outcome == 'success' }}
uses: actions/upload-artifact@v6
with:
name: fetch-reconciliation-plans-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/reconciliation-plans
if-no-files-found: error
retention-days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
- name: Upload reconciliation plan and review evidence
if: ${{ always() && steps.preflight.outcome == 'failure' }}
uses: actions/upload-artifact@v6
with:
name: fetch-reconciliation-review-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/reconciliation-plans
if-no-files-found: ignore
retention-days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
publish_ready:
needs: [prepare, reconciliation_preflight]
if: ${{ always() && needs.prepare.result == 'success' && (needs.prepare.outputs.publish == 'false' || needs.reconciliation_preflight.result == 'success') }}
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
actions: read
contents: write
outputs:
results_artifact_name: ${{ steps.publish.outputs.results_artifact_name }}
overall_status: ${{ steps.publish.outputs.overall_status }}
final_target_sha: ${{ steps.publish.outputs.final_target_sha }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ needs.prepare.outputs.master_sha }}
fetch-depth: 0
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- name: Validate immutable Fetch publication selection
env:
EXPECTED_SELECTION_SHA256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
run: |
set -euo pipefail
selection="$RUNNER_TEMP/publication-selection/publication-selection.json"
node scripts/docs-workflow/publication-contracts.js validate-selection "$selection"
actual=$(node -e 'const fs=require("node:fs");process.stdout.write(JSON.parse(fs.readFileSync(process.argv[1],"utf8")).selectionSha256)' "$selection")
[[ "$actual" == "$EXPECTED_SELECTION_SHA256" ]]
- id: publish
name: Publish ready Fetch units in producer completion FIFO order
uses: actions/github-script@v8
env:
GITHUB_TOKEN: ${{ github.token }}
PUBLISH: ${{ needs.prepare.outputs.publish }}
with:
script: |
const mode = process.env.PUBLISH === 'true' ? 'publish' : 'artifact_only'
await exec.exec('node', [
'scripts/docs-workflow/publication-coordinator.js',
'--selection', `${process.env.RUNNER_TEMP}/publication-selection/publication-selection.json`,
'--mode', mode,
'--poll-milliseconds', '10000',
'--candidate-polls', '6',
'--max-publish-attempts', '10',
])
reconcile_reference_state:
needs: [prepare, publish_ready]
if: ${{ always() && needs.prepare.outputs.publish == 'true' && needs.publish_ready.outputs.results_artifact_name != '' }}
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
actions: read
contents: write
outputs:
final_target_sha: ${{ steps.reconcile.outputs.final_target_sha }}
status: ${{ steps.reconcile.outputs.status }}
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}', fetch-depth: 0 }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- name: Download immutable Fetch publication results
uses: actions/download-artifact@v7
with:
name: ${{ needs.publish_ready.outputs.results_artifact_name }}
path: ${{ runner.temp }}/publication-results
- id: reconcile
name: Reconcile and publish Fetch Reference derived state
run: |
set -euo pipefail
node scripts/docs-workflow/fetch-reference-reconciliation.js reconcile \
--selection "$RUNNER_TEMP/publication-selection/publication-selection.json" \
--results "$RUNNER_TEMP/publication-results/publication-results.json" \
--repository-root "$GITHUB_WORKSPACE" \
--runner-temp "$RUNNER_TEMP" \
--remote origin
record_pending_reconciliation:
needs: [prepare, publish_ready, reconcile_reference_state]
if: ${{ always() && needs.prepare.outputs.publish == 'true' && needs.prepare.outputs.run_translations == 'false' && needs.prepare.outputs.has_translation_units == 'true' && needs.publish_ready.result == 'success' && needs.reconcile_reference_state.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
actions: read
contents: read
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}', fetch-depth: 0 }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- name: Download immutable Fetch publication results
uses: actions/download-artifact@v7
with:
name: ${{ needs.publish_ready.outputs.results_artifact_name }}
path: ${{ runner.temp }}/publication-results
- name: Record pending reconciliation evidence
env:
TARGET_BASELINE_SHA: ${{ needs.reconcile_reference_state.outputs.final_target_sha }}
run: |
set -euo pipefail
node scripts/docs-workflow/fetch-reconciliation-plans.js generate \
--allow-review \
--selection "$RUNNER_TEMP/publication-selection/publication-selection.json" \
--results "$RUNNER_TEMP/publication-results/publication-results.json" \
--repository "$GITHUB_WORKSPACE" \
--target-baseline-sha "$TARGET_BASELINE_SHA" \
--output "$RUNNER_TEMP/pending-reconciliation"
- name: Upload pending reconciliation evidence
uses: actions/upload-artifact@v6
with:
name: fetch-pending-reconciliation-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/pending-reconciliation
if-no-files-found: error
retention-days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
source_publication_barrier:
needs: [prepare, publish_ready, reconcile_reference_state]
if: ${{ always() && needs.prepare.outputs.run_translations == 'true' && needs.prepare.outputs.publish == 'true' && needs.reconcile_reference_state.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}', fetch-depth: 1 }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- name: Download immutable Fetch publication results
uses: actions/download-artifact@v7
with:
name: ${{ needs.publish_ready.outputs.results_artifact_name }}
path: ${{ runner.temp }}/publication-results
- name: Block paid translation until selected sources are published
run: |
node scripts/docs-workflow/source-publication-barrier.js \
--selection "$RUNNER_TEMP/publication-selection/publication-selection.json" \
--results "$RUNNER_TEMP/publication-results/publication-results.json"
prepare_translation_handoff:
needs: [prepare, source_publication_barrier, publish_ready, reconcile_reference_state]
if: ${{ always() && needs.prepare.outputs.run_translations == 'true' && needs.prepare.outputs.publish == 'true' && needs.source_publication_barrier.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
handoff_json: ${{ steps.handoff.outputs.handoff_json }}
workflow_ref: ${{ steps.handoff.outputs.workflow_ref }}
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}', fetch-depth: 0 }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- name: Download immutable Fetch publication results
uses: actions/download-artifact@v7
with:
name: ${{ needs.publish_ready.outputs.results_artifact_name }}
path: ${{ runner.temp }}/publication-results
- name: Prepare authenticated reconciliation plans
env:
TARGET_BASELINE_SHA: ${{ needs.reconcile_reference_state.outputs.final_target_sha }}
run: |
set -euo pipefail
node scripts/docs-workflow/fetch-reconciliation-plans.js generate \
--selection "$RUNNER_TEMP/publication-selection/publication-selection.json" \
--results "$RUNNER_TEMP/publication-results/publication-results.json" \
--repository "$GITHUB_WORKSPACE" \
--target-baseline-sha "$TARGET_BASELINE_SHA" \
--output "$RUNNER_TEMP/reconciliation-plans"
- id: handoff
name: Validate exact downstream translation handoff
env:
SELECTED_GROUP: ${{ needs.prepare.outputs.selected_group }}
TARGET_BASELINE_SHA: ${{ needs.reconcile_reference_state.outputs.final_target_sha }}
WORKFLOW_REF: ${{ github.ref_name }}
run: |
set -euo pipefail
node -e 'require("./scripts/docs-workflow/resolve-docs-refs").assertSafeGitRef(process.env.WORKFLOW_REF)'
node scripts/docs-workflow/translation-handoff.js \
--locale all \
--group "$SELECTED_GROUP" \
--fetch-selection "$RUNNER_TEMP/publication-selection/publication-selection.json" \
--fetch-results "$RUNNER_TEMP/publication-results/publication-results.json" \
--target-baseline-sha "$TARGET_BASELINE_SHA" \
--reconciliation-plans-dir "$RUNNER_TEMP/reconciliation-plans" \
> "$RUNNER_TEMP/validated-translation-handoff.json"
handoff_json=$(cat "$RUNNER_TEMP/validated-translation-handoff.json")
node scripts/docs-workflow/translation-handoff.js --handoff-json "$handoff_json" > /dev/null
printf 'handoff_json=%s\nworkflow_ref=%s\n' "$handoff_json" "$WORKFLOW_REF" >> "$GITHUB_OUTPUT"
- name: Upload validated schema-v3 translation handoff
uses: actions/upload-artifact@v6
with:
name: translation-handoff-v3-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/validated-translation-handoff.json
if-no-files-found: error
retention-days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
dispatch_translations:
needs: [prepare, prepare_translation_handoff]
if: ${{ always() && needs.prepare.outputs.run_translations == 'true' && needs.prepare.outputs.publish == 'true' && needs.prepare_translation_handoff.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
actions: write
contents: read
outputs:
run_url: ${{ steps.dispatch.outputs.run_url }}
run_id: ${{ steps.dispatch.outputs.run_id }}
steps:
- id: dispatch
name: Dispatch the single translation workflow
env:
GH_TOKEN: ${{ github.token }}
WORKFLOW_REF: ${{ needs.prepare_translation_handoff.outputs.workflow_ref }}
HANDOFF_JSON: ${{ needs.prepare_translation_handoff.outputs.handoff_json }}
REQUEST_ID: ${{ github.run_id }}-${{ github.run_attempt }}
run: |
set -euo pipefail
[[ "$REQUEST_ID" =~ ^[1-9][0-9]*-[1-9][0-9]*$ ]]
expected_title="translate docs ($REQUEST_ID)"
gh workflow run translate-codex.yml --repo "$GITHUB_REPOSITORY" --ref "$WORKFLOW_REF" -f handoff_json="$HANDOFF_JSON" -f mode=auto -f publish=true -f request_id="$REQUEST_ID"
run_url=
for _ in {1..12}; do
runs_json=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow translate-codex.yml --event workflow_dispatch --limit 50 --json displayTitle,url,headBranch)
run_matches=$(jq -r --arg title "$expected_title" --arg ref "$WORKFLOW_REF" '.[] | select(.displayTitle == $title and .headBranch == $ref) | .url' <<< "$runs_json")
run_urls=()
[[ -z "$run_matches" ]] || mapfile -t run_urls <<< "$run_matches"
if (( ${#run_urls[@]} > 1 )); then
echo "ambiguous downstream translation runs for $expected_title on $WORKFLOW_REF" >&2
exit 1
fi
if (( ${#run_urls[@]} == 1 )); then
run_url=${run_urls[0]}
break
fi
sleep 5
done
[[ "$run_url" =~ ^https://github\.com/$GITHUB_REPOSITORY/actions/runs/[1-9][0-9]*$ ]]
run_id=${run_url##*/}
printf 'run_url=%s\nrun_id=%s\n' "$run_url" "$run_id" >> "$GITHUB_OUTPUT"
printf 'Downstream translation run: %s\n' "$run_url" >> "$GITHUB_STEP_SUMMARY"
- name: Create translation handoff monitor metadata
env:
PARENT_RUN_ID: ${{ github.run_id }}
CHILD_RUN_ID: ${{ steps.dispatch.outputs.run_id }}
CHILD_RUN_URL: ${{ steps.dispatch.outputs.run_url }}
run: |
mkdir -p "$RUNNER_TEMP/docs-translation-handoff"
node -e 'const fs=require("node:fs");const value={schemaVersion:1,parentRunId:Number(process.env.PARENT_RUN_ID),childRunId:Number(process.env.CHILD_RUN_ID),childRunUrl:process.env.CHILD_RUN_URL};if(!Number.isSafeInteger(value.parentRunId)||!Number.isSafeInteger(value.childRunId))throw new Error("invalid handoff run id");fs.writeFileSync(process.argv[1],JSON.stringify(value)+"\n")' "$RUNNER_TEMP/docs-translation-handoff/handoff-metadata.json"
- name: Upload translation handoff monitor metadata
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: docs-translation-handoff-${{ github.run_id }}
path: ${{ runner.temp }}/docs-translation-handoff/handoff-metadata.json
retention-days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
verify:
needs: [prepare, publish_ready, reconcile_reference_state]
if: ${{ always() && needs.prepare.outputs.publish == 'true' && needs.reconcile_reference_state.result == 'success' && needs.reconcile_reference_state.outputs.final_target_sha != '' }}
uses: ./.github/workflows/_verify-docs.yml
with:
final_dev_sha: ${{ needs.reconcile_reference_state.outputs.final_target_sha }}
publication_selection_artifact_name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
publication_results_artifact_name: ${{ needs.publish_ready.outputs.results_artifact_name }}
master_sha: ${{ needs.prepare.outputs.master_sha }}
target_branch: ${{ needs.prepare.outputs.target_branch }}
aggregate:
needs: [prepare, publish_ready, reconcile_reference_state, prepare_translation_handoff, dispatch_translations, verify]
if: ${{ always() }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}' }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- name: Download immutable Fetch publication selection
uses: actions/download-artifact@v7
with:
name: ${{ needs.prepare.outputs.publication_selection_artifact_name }}
path: ${{ runner.temp }}/publication-selection
- name: Download immutable Fetch publication results
uses: actions/download-artifact@v7
with:
name: ${{ needs.publish_ready.outputs.results_artifact_name }}
path: ${{ runner.temp }}/publication-results
- id: aggregate
name: Aggregate terminal source and handoff results
env:
MODE: ${{ needs.prepare.outputs.publish == 'true' && 'publish' || 'artifact_only' }}
RUN_TRANSLATIONS: 'false'
SELECTED_GROUP: ${{ needs.prepare.outputs.selected_group }}
FINAL_VERIFICATION: ${{ needs.verify.outputs.status || 'skipped' }}
REVISION_RECONCILIATION: ${{ needs.verify.outputs.revision_status || 'skipped' }}
TRANSLATION_HANDOFF_REQUESTED: ${{ needs.prepare.outputs.run_translations }}
TRANSLATION_HANDOFF_RESULT: ${{ needs.dispatch_translations.result }}
TRANSLATION_HANDOFF_RUN_ID: ${{ needs.dispatch_translations.outputs.run_id }}
TRANSLATION_HANDOFF_RUN_URL: ${{ needs.dispatch_translations.outputs.run_url }}
VERIFY_JOB_RESULT: ${{ needs.verify.result }}
run: |
node scripts/docs-workflow/build-aggregate-input.js \
--publication-selection "$RUNNER_TEMP/publication-selection/publication-selection.json" \
--publication-results "$RUNNER_TEMP/publication-results/publication-results.json" \
--output tmp/docs-workflow-results.json
node scripts/docs-workflow/aggregate-results.js --input tmp/docs-workflow-results.json --output tmp/docs-workflow-summary.md
- name: Download current English Guides reports
if: ${{ always() && (needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides')) }}
continue-on-error: true
uses: actions/download-artifact@v7
with:
name: docs-checkpoint-guides-en-${{ github.run_id }}-reports
path: tmp/card-guides-reports/en
- name: Download current Chinese Guides reports
if: ${{ always() && (needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides')) }}
continue-on-error: true
uses: actions/download-artifact@v7
with:
name: docs-checkpoint-guides-zh-CN-${{ github.run_id }}-reports
path: tmp/card-guides-reports/zh-CN
- id: report_artifact_links
name: Resolve exact Guides report artifact links
if: ${{ always() }}
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
artifacts_json="$RUNNER_TEMP/docs-report-artifacts.json"
gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts?per_page=100" | jq -s '[.[].artifacts[]]' > "$artifacts_json"
node scripts/docs-workflow/resolve-card-artifact-links.js --repository "$GITHUB_REPOSITORY" --run-id "$GITHUB_RUN_ID" --artifacts-json "$artifacts_json"
- id: reports
name: Collect card report summaries
if: ${{ always() }}
continue-on-error: true
env:
CARD_REPORT_STARTED_AT: ${{ needs.prepare.outputs.card_started_at }}
CARD_REPORT_REF: ${{ needs.publish_ready.outputs.final_target_sha }}
CARD_REPORT_ARTIFACT_URL_EN: ${{ steps.report_artifact_links.outputs.en_url }}
CARD_REPORT_ARTIFACT_URL_ZH_CN: ${{ steps.report_artifact_links.outputs.zh_cn_url }}
CARD_GUIDES_REPORTS_ROOT: tmp/card-guides-reports
CARD_EXPECT_EN_GUIDES_REPORTS: ${{ needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides') }}
CARD_EXPECT_ZH_GUIDES_REPORTS: ${{ needs.prepare.outputs.selected_group == 'all' || contains(needs.prepare.outputs.selected_group, 'guides') }}
CARD_BASE_NOTES_JSON: ${{ steps.aggregate.outputs.notes_json }}
run: node scripts/collect-build-card-notes.js
- name: Create final card report artifact
if: ${{ always() }}
continue-on-error: true
run: |
set -euo pipefail
reports_file="${{ steps.reports.outputs.card_notes_file }}"
if [[ -z "$reports_file" || ! -f "$reports_file" ]]; then
reports_file="$RUNNER_TEMP/card-notes.json"
printf '[]\n' > "$reports_file"
fi
printf '%s\n' "${CARD_SUMMARY:-Documentation workflow report unavailable.}" > "$RUNNER_TEMP/card-summary.txt"
node scripts/docs-workflow/docs-card-report.js create --run-id "$GITHUB_RUN_ID" --overall-status "$OVERALL_STATUS" --summary-file "$RUNNER_TEMP/card-summary.txt" --reports-json "$reports_file" --output tmp/docs-card-report/card-report.json
env:
OVERALL_STATUS: ${{ steps.aggregate.outputs.overall_status == 'success' && 'success' || 'failure' }}
CARD_SUMMARY: ${{ steps.aggregate.outputs.summary_text }}
- name: Upload final card report artifact
if: ${{ always() }}
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: docs-card-report-${{ github.run_id }}
path: tmp/docs-card-report/card-report.json
if-no-files-found: warn
retention-days: ${{ fromJSON(needs.prepare.outputs.retention_days) }}
- name: Fail unsuccessful workflow
if: ${{ steps.aggregate.outputs.overall_status != 'success' }}
run: exit 1
finalize_card_fallback:
needs: [prepare, aggregate, monitor_docs_progress]
if: ${{ always() && needs.prepare.outputs.card_id != '' }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: read
steps:
- uses: actions/checkout@v5
with: { ref: '${{ needs.prepare.outputs.master_sha }}' }
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- uses: actions/download-artifact@v7
continue-on-error: true
with:
name: docs-card-report-${{ github.run_id }}
path: tmp/docs-card-report
- name: Perform best-effort terminal card update
continue-on-error: true
run: node scripts/docs-workflow/monitor-docs-progress.js --finalize-only --report-file tmp/docs-card-report/card-report.json
env:
GITHUB_TOKEN: ${{ github.token }}
CARD_ID: ${{ needs.prepare.outputs.card_id }}
CARD_STARTED_AT: ${{ needs.prepare.outputs.card_started_at }}
CARD_TARGET_BRANCH: ${{ needs.prepare.outputs.target_branch }}
SELECTED_GROUP: ${{ needs.prepare.outputs.selected_group }}
PUBLISH_ENABLED: ${{ needs.prepare.outputs.publish }}
RUN_TRANSLATIONS: ${{ needs.prepare.outputs.run_translations }}
PUBLICATION_RUN_ATTEMPT: ${{ github.run_attempt }}
PUBLICATION_SELECTION_SHA256: ${{ needs.prepare.outputs.publication_selection_sha256 }}
APP_ID: ${{ secrets.APP_ID }}
APP_SECRET: ${{ secrets.APP_SECRET }}
FEISHU_HOST: ${{ vars.FEISHU_HOST }}
You can’t perform that action at this time.
