-
Notifications
You must be signed in to change notification settings - Fork 116
269 lines (245 loc) · 9.02 KB
/
Copy pathdeploy.yaml
File metadata and controls
269 lines (245 loc) · 9.02 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
name: Deploy
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
merge_group:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: [""]
stage: ["commit", "push"]
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: recursive
persist-credentials: false
- name: Agent product index guard
run: python3 scripts/generate-agent-product-index.py --check
- name: Agent doc lint (changed files)
shell: bash
run: |
set -euo pipefail
FROM_REF=""
TO_REF=""
if [ "${{ github.event_name }}" == "push" ]
then
if [ "${{ github.event.created }}" != "true" ]
then
FROM_REF="${{ github.event.before }}"
TO_REF="${{ github.event.after }}"
fi
elif [ "${{ github.event_name }}" == "pull_request" ]
then
FROM_REF="${{ github.event.pull_request.base.sha }}"
TO_REF="${{ github.event.pull_request.head.sha }}"
elif [ "${{ github.event_name }}" == "merge_group" ]
then
FROM_REF="${{ github.event.merge_group.base_sha }}"
TO_REF="${{ github.event.merge_group.head_sha }}"
fi
if [ -z "$FROM_REF" ] || [ -z "$TO_REF" ]
then
echo "No diff range available for this event, skipping agent-doc-lint."
exit 0
fi
mapfile -t files < <(git diff --name-only "$FROM_REF" "$TO_REF" | grep -E '^(docs|i18n/en/docusaurus-plugin-content-docs/current)/.*\.(md|mdx)$' || true)
if [ "${#files[@]}" -eq 0 ]
then
echo "No markdown docs changed, skipping agent-doc-lint."
exit 0
fi
echo "Running agent-doc-lint on ${#files[@]} file(s)."
./scripts/agent-doc-lint.sh "${files[@]}"
- name: Agent doc drift guard
shell: bash
run: |
set -euo pipefail
./scripts/agent-doc-drift-guard.sh
- name: Agent doc translation guard
shell: bash
run: |
set -euo pipefail
./scripts/agent-doc-translation-guard.sh
- name: pre-commit checks
shell: bash
run: |
set -o pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends webp pipx
pipx ensurepath
pipx install pre-commit
CI_FAIL=false
EXTRA_ARGS=("--all-files")
if [ "${{ github.event_name }}" == "push" ]
then
if [ "${{ github.event.created }}" != "true" ]
then
git fetch origin ${{ github.event.before }}:old_head
FROM_REF="${{ github.event.before }}"
TO_REF="${{ github.event.after }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
elif [ "${{ github.event_name }}" == "pull_request" ]
then
FROM_REF="${{ github.event.pull_request.base.sha }}"
TO_REF="${{ github.event.pull_request.head.sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
elif [ "${{ github.event_name }}" == "merge_group" ]
then
git fetch origin ${{ github.event.merge_group.base_sha }}:old_head
FROM_REF="${{ github.event.merge_group.base_sha }}"
TO_REF="${{ github.event.merge_group.head_sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
EXTRA_ARGS+=("--hook-stage" "${{ matrix.stage }}" "${{ matrix.test }}")
if ! pre-commit run --show-diff-on-failure "${EXTRA_ARGS[@]}" 2>&1 | tee /tmp/ci_result.log
then
CI_FAIL=true
fi
if $CI_FAIL
then
echo ''
echo '=== Issue detected! ==='
echo 'Suggest changes are listed above.'
echo 'Please install pre-commit and run `pre-commit run --all-files` to fix it.'
echo 'Strongly recommended to run `pre-commit install` to catch issues before pushing.'
echo 'You can learn more about pre-commit from https://pre-commit.com/'
exit 1
fi
test-optional:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ["check-external-links", "gitown"]
stage: ["manual"]
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: recursive
persist-credentials: false
- name: pre-commit check-external-links
shell: bash
run: |
set -o pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends webp pipx
pipx ensurepath
pipx install pre-commit
CI_FAIL=false
EXTRA_ARGS=("--all-files")
if [ "${{ github.event_name }}" == "push" ]
then
if [ "${{ github.event.created }}" != "true" ]
then
git fetch origin ${{ github.event.before }}:old_head
FROM_REF="${{ github.event.before }}"
TO_REF="${{ github.event.after }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
elif [ "${{ github.event_name }}" == "pull_request" ]
then
FROM_REF="${{ github.event.pull_request.base.sha }}"
TO_REF="${{ github.event.pull_request.head.sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
elif [ "${{ github.event_name }}" == "merge_group" ]
then
git fetch origin ${{ github.event.merge_group.base_sha }}:old_head
FROM_REF="${{ github.event.merge_group.base_sha }}"
TO_REF="${{ github.event.merge_group.head_sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
EXTRA_ARGS+=("--hook-stage" "${{ matrix.stage }}" "${{ matrix.test }}")
if ! pre-commit run --show-diff-on-failure "${EXTRA_ARGS[@]}" 2>&1 | tee /tmp/ci_result.log
then
CI_FAIL=true
fi
if $CI_FAIL
then
echo ''
echo '=== Issue detected! ==='
echo 'Suggest changes are listed above.'
echo 'Please install pre-commit and run `pre-commit run --all-files` to fix it.'
echo 'Strongly recommended to run `pre-commit install` to catch issues before pushing.'
echo 'You can learn more about pre-commit from https://pre-commit.com/'
exit 1
fi
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
steps:
- name: Checkout template
uses: actions/checkout@v7
with:
token: "${{ secrets.PRIVATE_REPO_TOKEN }}"
repository: "radxa-docs/docs-template"
- name: Checkout contents
uses: actions/checkout@v7
with:
path: "contents"
fetch-depth: 0
submodules: recursive
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
cache-dependency-path: yarn.lock
- name: Cache Docusaurus bundler
uses: actions/cache@v6
with:
path: node_modules/.cache/rspack
key: rspack-${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ github.sha }}
restore-keys: |
rspack-${{ runner.os }}-${{ hashFiles('yarn.lock') }}-
rspack-${{ runner.os }}-
- name: Install dependencies
run: yarn install
- name: Fetch Baidu Tongji data
run: node ./contents/.github/scripts/baidu-tongji.js
env:
BAIDU_TONGJI_ACCESS_TOKEN: ${{ secrets.BAIDU_TONGJI_ACCESS_TOKEN }}
BAIDU_TONGJI_REFRESH_TOKEN: ${{ secrets.BAIDU_TONGJI_REFRESH_TOKEN }}
BAIDU_TONGJI_CLIENT_ID: ${{ secrets.BAIDU_TONGJI_CLIENT_ID }}
BAIDU_TONGJI_CLIENT_SECRET: ${{ secrets.BAIDU_TONGJI_CLIENT_SECRET }}
- name: Generate latest updates JSON
run: node ./contents/.github/scripts/latest-updates.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Build
run: |
export NODE_OPTIONS="--max-old-space-size=12288"
yarn build
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: "./build"
deploy:
needs: build
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' && github.ref_name == 'main'
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
steps:
- name: Setup Pages
id: setup-pages
uses: actions/configure-pages@v6
continue-on-error: true
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v5
if: steps.setup-pages.outcome == 'success'