-
Notifications
You must be signed in to change notification settings - Fork 2.5k
212 lines (191 loc) · 6.73 KB
/
Copy pathci-doc-checker.yml
File metadata and controls
212 lines (191 loc) · 6.73 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
name: CI DOC Checker
on:
pull_request_target:
types:
- opened
- synchronize
branches:
- main
- 'branch*'
permissions:
issues: write
pull-requests: write
jobs:
doc-checker:
runs-on: ubuntu-latest
name: DOC FILTER
if: >
!contains(github.event.pull_request.title, '(sync #') &&
!contains(github.event.pull_request.labels.*.name, 'sync') &&
(!startsWith(github.head_ref, github.base_ref) || !contains(github.head_ref, '-sync-'))
outputs:
output1: ${{ steps.doc-changes-info.outputs.doc }}
steps:
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
doc:
- 'docs/**'
- name: DOC CHECK INFO
id: doc-changes-info
run: |
echo "doc=${{ steps.changes.outputs.doc }}" >> $GITHUB_OUTPUT
remove-doc-label:
needs: doc-checker
runs-on: ubuntu-latest
name: REMOVE DOC LABEL
if: ${{ needs.doc-checker.outputs.output1 != 'true' }}
steps:
- name: remove document label
uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: documentation
add-doc-label:
needs: doc-checker
runs-on: ubuntu-latest
name: ADD DOC LABEL
if: ${{ needs.doc-checker.outputs.output1 == 'true' }}
steps:
- name: add document label
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: documentation
markdownlint:
runs-on: ubuntu-latest
needs: add-doc-label
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- name: clean
run: |
rm -rf ${{ github.workspace }}
mkdir -p ${{ github.workspace }}
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout PR
run: |
BRANCH=${{steps.branch.outputs.branch}}
git config --global user.name "wanpengfei-git";
git config --global user.email "wanpengfei91@163.com";
git checkout $BRANCH;
git pull;
BRANCH_NAME="${BRANCH}-${PR_NUMBER}";
git fetch origin pull/${PR_NUMBER}/head:${BRANCH_NAME};
git checkout $BRANCH_NAME;
git checkout -b merge_pr;
git merge --squash --no-edit ${BRANCH} || (echo "::error::Merge conflict, please check." && exit -1);
- uses: actions/setup-node@v6
with:
node-version: 24
- uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323
id: changed-files
with:
files: |
docs/en/**/*.md
docs/ja/**/*.md
docs/zh/**/*.md
separator: ","
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
- uses: DavidAnson/markdownlint-cli2-action@v21
if: steps.changed-files.outputs.any_changed == 'true'
with:
config: 'docs/.markdownlint.json'
globs: ${{ steps.changed-files.outputs.all_changed_files }}
separator: ","
docusaurus-build:
runs-on: ubuntu-latest
needs: markdownlint # Only runs if markdownlint passes!
env:
PR_NUMBER: ${{ github.event.number }}
steps:
# 1. Replicate the branch info and complex checkout logic
- name: clean
run: |
rm -rf ${{ github.workspace }}
mkdir -p ${{ github.workspace }}
- name: BRANCH INFO
id: branch
run: |
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout PR
run: |
BRANCH=${{steps.branch.outputs.branch}}
git config --global user.name "docs-automation[bot]"
git config --global user.email "docs-automation[bot]@starrocks.io"
git checkout $BRANCH
git pull
BRANCH_NAME="${BRANCH}-${PR_NUMBER}"
git fetch origin pull/${PR_NUMBER}/head:${BRANCH_NAME}
git checkout $BRANCH_NAME
git checkout -b merge_pr
git merge --squash --no-edit ${BRANCH} || (echo "::error::Merge conflict, please check." && exit -1)
# 2. Replicate the Node.js setup
- uses: actions/setup-node@v6
with:
node-version: 24
- name: docusaurus-mdx-checker
run: |
npx docusaurus-mdx-checker -c docs
- name: link check
if: always()
uses: lycheeverse/lychee-action@v2.8.0
with:
fail: true
args: >
--config docs/lychee.toml
--offline "docs/**/*.md"
# 3. Your original Docusaurus build logic
- name: Docusaurus build
env:
NODE_OPTIONS: --max-old-space-size=9216
DISABLE_VERSIONING: true
DOCUSAURUS_IGNORE_SSG_WARNINGS: true
working-directory: ./docs/docusaurus
run: |
rm -rf ./docs
rm -rf ./i18n/zh/docusaurus-plugin-content-docs/current
mkdir -p ./i18n/zh/docusaurus-plugin-content-docs
mv ../en ./docs
rm -rf ./docs/release_notes ./docs/ecosystem_release
mv ../zh ./i18n/zh/docusaurus-plugin-content-docs/current
rm -rf ./i18n/zh/docusaurus-plugin-content-docs/current/release_notes ./i18n/zh/docusaurus-plugin-content-docs/current/ecosystem_release
# Using package.json and yarn.lock from a PR is not safe, so copy from main branch.
rm package.json
rm yarn.lock
curl -O https://raw.githubusercontent.com/StarRocks/starrocks/refs/heads/main/docs/docusaurus/package.json
curl -O https://raw.githubusercontent.com/StarRocks/starrocks/refs/heads/main/docs/docusaurus/yarn.lock
yarn install --frozen-lockfile
yarn clear
yarn build
behavior-unchange:
runs-on: ubuntu-latest
needs: add-doc-label
env:
PR_NUMBER: ${{ github.event.number }}
REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Set Body
run: |
body=$(gh pr view ${PR_NUMBER} -R ${REPO} --json body -q .body)
body=${body//"[x] Yes, this PR will result in a change in behavior."/"[ ] Yes, this PR will result in a change in behavior."}
body=${body//"[ ] No, this PR will not result in a change in behavior."/"[x] No, this PR will not result in a change in behavior."}
gh pr edit ${PR_NUMBER} -R ${REPO} -b "$body"