-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 1.67 KB
/
validate-pr.yml
File metadata and controls
67 lines (56 loc) · 1.67 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
name: 插件 PR 自动审核
on:
pull_request:
branches: [main]
paths:
- 'plugins.v4.json'
permissions:
contents: read
jobs:
validate:
name: 校验插件索引
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout base branch for diff
run: |
git fetch origin ${{ github.base_ref }} --depth=1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Validate plugins.v4.json (with diff)
id: validate
run: |
set +e
node scripts/validate-plugin.mjs --diff origin/${{ github.base_ref }} 2>&1 | tee validation-output.txt
VALIDATE_EXIT=${PIPESTATUS[0]}
echo "exit_code=${VALIDATE_EXIT}" >> $GITHUB_OUTPUT
exit 0
- name: Save validation result as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: validation-result
path: |
validation-output.txt
retention-days: 1
- name: Save PR metadata
if: always()
run: |
mkdir -p pr-metadata
echo "${{ github.event.pull_request.number }}" > pr-metadata/pr-number.txt
echo "${{ steps.validate.outputs.exit_code }}" > pr-metadata/exit-code.txt
- name: Upload PR metadata
if: always()
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: pr-metadata/
retention-days: 1
- name: Fail if validation failed
if: steps.validate.outputs.exit_code != '0'
run: exit 1