-
Notifications
You must be signed in to change notification settings - Fork 10
72 lines (60 loc) · 2.06 KB
/
pr.yml
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
name: Validate Mod Json
on:
# Runs on pushes targeting the default branch
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
pr_number:
description: "The PR number to check against"
default: ""
jobs:
# Single deploy job since we're just deploying
test:
name: pr-check-mods
runs-on: ubuntu-latest
steps:
- name: Set PR number
run: |
if [ "${{ github.event.pull_request.number }}" != "" ]; then
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
fi
if [ "${{ github.event.client_payload.pr_number }}" != "" ]; then
echo "PR_NUMBER=${{ github.event.client_payload.pr_number }}" >> $GITHUB_ENV
fi
if [ "${{ github.event.inputs.pr_number }}" != "" ]; then
echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> $GITHUB_ENV
fi
- name: Check PR number
run: |
if [ "$PR_NUMBER" == "" ]; then
echo "PR number not set"
false
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Get changed files
id: get_changed_files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" | jq -r '.[].filename' > changed-files.txt
- name: Get the mods folder of the PR
id: download_mods_json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
rm -r mods
wget "https://api.github.com/repos/$GITHUB_REPOSITORY/tarball/pull/$PR_NUMBER/head" -qO - | tar -xzvf - --strip-components=1 --wildcards '*/mods/'
- name: Install npm modules
run: |
(cd source/scripts && npm install)
- name: Validate json
run: |
cd source/scripts
npx tsx ./pr-check.ts