blob: 202355bd922861df953ae4087f96cfcb8dea6cae (
plain) (
blame)
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
|
# Запуск только когда на PR вешают лейбл doc_translate.
name: ydbdoc-review (doc_translate label)
on:
pull_request_target:
types: [labeled]
paths:
- "ydb/docs/**"
permissions:
contents: write
pull-requests: write
issues: write
jobs:
ydbdoc-review:
if: |
github.event.label.name == 'doc_translate'
runs-on: ubuntu-latest
concurrency:
group: ydbdoc-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout PR head
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fetch merge base ref
run: |
git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}
- name: Documentation translation review
uses: ydb-platform/[email protected]
with:
repo: ${{ github.repository }}
pr: ${{ github.event.pull_request.number }}
merge_base_with: origin/${{ github.event.pull_request.base.ref }}
# dry_run: "true" # раскомментируйте для прогона без записи/commit/push
# no_commit: "true" # или только запись файлов без коммита (см. README)
env:
YANDEX_CLOUD_FOLDER_DOC_REVIEW: ${{ secrets.YANDEX_CLOUD_FOLDER_DOC_REVIEW }}
YANDEX_CLOUD_API_KEY_DOC_REVIEW: ${{ secrets.YANDEX_CLOUD_API_KEY_DOC_REVIEW }}
YDBDOC_REVIEW_ENABLED: ${{ vars.YDBDOC_REVIEW_ENABLED }}
YDBDOC_MODEL_CHECK: ${{ vars.YDBDOC_MODEL_CHECK }}
YDBDOC_MODEL_TRANSLATE: ${{ vars.YDBDOC_MODEL_TRANSLATE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
YDBDOC_REPO_PATH: ${{ github.workspace }}
- name: Trigger docs rebuild for translation PR
if: ${{ !cancelled() }}
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const sourcePr = context.payload.pull_request.number;
const head = `${owner}:ydbdoc-review/pr-${sourcePr}`;
let translationPr = null;
// Translation PR creation can lag a bit right after doc_translate push.
for (let attempt = 1; attempt <= 6; attempt++) {
const { data: pulls } = await github.rest.pulls.list({
owner,
repo,
state: 'open',
head,
per_page: 1,
});
if (pulls[0]) {
translationPr = pulls[0];
break;
}
if (attempt < 6) {
core.info(`Translation PR not found yet (${attempt}/6), retrying...`);
await new Promise((resolve) => setTimeout(resolve, 5000));
}
}
if (!translationPr) {
core.warning(`Open translation PR not found for head ${head}. rebuild_docs was not added; rebuild can be triggered manually.`);
return;
}
await github.rest.issues.addLabels({
owner,
repo,
issue_number: translationPr.number,
labels: ['rebuild_docs'],
});
core.info(`Added rebuild_docs to PR #${translationPr.number}`);
|