Repository navigation
352 lines (299 loc) 路 12.6 KB
/
Copy pathmain.yml
File metadata and controls
352 lines (299 loc) 路 12.6 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
name: Repo Checks
on:
pull_request_target:
branches: [main]
types: [opened, synchronize, reopened]
pull_request:
branches: [main]
push:
branches: [main]
permissions:
contents: read
jobs:
pull-request-trust:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target'
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Checkout trusted base checks
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.base.ref }}
path: .trusted-base
fetch-depth: 0
persist-credentials: false
- name: Check PR author account age
env:
GITHUB_TOKEN: ${{ github.token }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_AUTHOR_MINIMUM_AGE_DAYS: ${{ vars.PR_AUTHOR_MINIMUM_AGE_DAYS || '30' }}
PR_AUTHOR_AGE_ALLOWLIST: ${{ vars.PR_AUTHOR_AGE_ALLOWLIST || 'PatrickJS,dependabot[bot],Copilot' }}
run: |
node .trusted-base/scripts/check-pr-author.mjs \
--username "$PR_AUTHOR" \
--minimum-age-days "$PR_AUTHOR_MINIMUM_AGE_DAYS" \
--allowlist "$PR_AUTHOR_AGE_ALLOWLIST"
readme-hygiene:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' || github.event_name == 'push'
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Checkout trusted base checks
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.base.ref }}
path: .trusted-base
fetch-depth: 0
persist-credentials: false
- name: Checkout pull request content
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: pr
fetch-depth: 0
persist-credentials: false
- name: Determine pull request changed files
if: github.event_name == 'pull_request_target'
shell: bash
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
git -C pr remote add trusted-base "$GITHUB_SERVER_URL/${{ github.repository }}.git"
git -C pr fetch --no-tags trusted-base "$BASE_REF"
base="$(git -C pr rev-parse FETCH_HEAD)"
git -C pr diff --name-only "$base"...HEAD > pr/.changed-files
git -C pr diff --unified=0 "$base"...HEAD -- README.md > pr/.readme.diff || true
- name: Run trusted README hygiene checks
if: github.event_name == 'pull_request_target'
run: node .trusted-base/scripts/check-readme-hygiene.mjs --root "$GITHUB_WORKSPACE/pr" --changed-files .changed-files --diff-file .readme.diff
- name: Checkout push content
if: github.event_name == 'push'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Determine push changed files
if: github.event_name == 'push'
shell: bash
run: |
if [[ -n "${{ github.event.before }}" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
base="${{ github.event.before }}"
else
base="$(git rev-list --max-parents=0 HEAD)"
fi
git diff --name-only "$base"...HEAD > .changed-files
git diff --unified=0 "$base"...HEAD -- README.md > .readme.diff || true
- name: Run README hygiene checks
if: github.event_name == 'push'
run: node scripts/check-readme-hygiene.mjs --changed-files .changed-files --diff-file .readme.diff
rule-hygiene:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' || github.event_name == 'push'
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Checkout trusted base checks
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.base.ref }}
path: .trusted-base
fetch-depth: 0
persist-credentials: false
- name: Checkout pull request content
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: pr
fetch-depth: 0
persist-credentials: false
- name: Determine pull request changed files
if: github.event_name == 'pull_request_target'
shell: bash
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
git -C pr remote add trusted-base "$GITHUB_SERVER_URL/${{ github.repository }}.git"
git -C pr fetch --no-tags trusted-base "$BASE_REF"
base="$(git -C pr rev-parse FETCH_HEAD)"
git -C pr diff --name-only "$base"...HEAD > pr/.changed-files
- name: Run trusted rule hygiene checks
if: github.event_name == 'pull_request_target'
run: node .trusted-base/scripts/check-rule-hygiene.mjs --root "$GITHUB_WORKSPACE/pr" --changed-files .changed-files
- name: Checkout push content
if: github.event_name == 'push'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Determine push changed files
if: github.event_name == 'push'
shell: bash
run: |
if [[ -n "${{ github.event.before }}" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
base="${{ github.event.before }}"
else
base="$(git rev-list --max-parents=0 HEAD)"
fi
git diff --name-only "$base"...HEAD > .changed-files
- name: Run rule hygiene checks
if: github.event_name == 'push'
run: node scripts/check-rule-hygiene.mjs --changed-files .changed-files
issue-template-policy:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' || github.event_name == 'push'
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Checkout trusted base checks
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.base.ref }}
path: .trusted-base
fetch-depth: 0
persist-credentials: false
- name: Checkout pull request content
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: pr
fetch-depth: 0
persist-credentials: false
- name: Run trusted issue template policy checks
if: github.event_name == 'pull_request_target'
run: node .trusted-base/scripts/check-issue-template-policy.mjs --root "$GITHUB_WORKSPACE/pr"
- name: Checkout push content
if: github.event_name == 'push'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Run issue template policy checks
if: github.event_name == 'push'
run: node scripts/check-issue-template-policy.mjs
repo-security:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' || github.event_name == 'push'
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Checkout trusted base checks
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.base.ref }}
path: .trusted-base
fetch-depth: 0
persist-credentials: false
- name: Checkout pull request content
if: github.event_name == 'pull_request_target'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: pr
fetch-depth: 0
persist-credentials: false
- name: Determine pull request changed files
if: github.event_name == 'pull_request_target'
shell: bash
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
git -C pr remote add trusted-base "$GITHUB_SERVER_URL/${{ github.repository }}.git"
git -C pr fetch --no-tags trusted-base "$BASE_REF"
base="$(git -C pr rev-parse FETCH_HEAD)"
git -C pr diff --name-only "$base"...HEAD > pr/.changed-files
- name: Run trusted repo security checks
if: github.event_name == 'pull_request_target'
run: node .trusted-base/scripts/check-repo-security.mjs --root "$GITHUB_WORKSPACE/pr" --changed-files .changed-files
- name: Checkout push content
if: github.event_name == 'push'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Determine push changed files
if: github.event_name == 'push'
shell: bash
run: |
if [[ -n "${{ github.event.before }}" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
base="${{ github.event.before }}"
else
base="$(git rev-list --max-parents=0 HEAD)"
fi
git diff --name-only "$base"...HEAD > .changed-files
- name: Run repo security checks
if: github.event_name == 'push'
run: node scripts/check-repo-security.mjs --changed-files .changed-files
test:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@10.20.0 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm test
awesome-lint:
name: awesome-lint
runs-on: ubuntu-latest
if: github.event_name != 'pull_request_target'
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@10.20.0 --activate
- name: Checkout trusted base checks
if: github.event_name == 'pull_request'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-base
fetch-depth: 1
persist-credentials: false
- name: Run trusted awesome-list checks
if: github.event_name == 'pull_request'
run: |
node .trusted-base/scripts/check-awesome-list.mjs --root "$GITHUB_WORKSPACE"
(cd .trusted-base && pnpm dlx awesome-lint@2.3.0 "$GITHUB_WORKSPACE/README.md")
- name: Install dependencies
if: github.event_name != 'pull_request'
run: pnpm install --frozen-lockfile
- name: Run awesome-list checks
if: github.event_name != 'pull_request'
run: |
pnpm run check:awesome-list
pnpm run check:awesome-list:upstream