-
Notifications
You must be signed in to change notification settings - Fork 22
44 lines (36 loc) · 1.27 KB
/
validate-config.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
name: Validate configuration files
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- 'main'
jobs:
validate_json_files:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Checkout main branch
run: |
echo "MAIN_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Save HEAD commit SHA
run: |
echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # Or your preferred version
- name: Validate JSON files
run: |
echo $HEAD_SHA
echo $MAIN_SHA
echo $(git merge-base $MAIN_SHA $HEAD_SHA)
git diff --quiet $(git merge-base $MAIN_SHA $HEAD_SHA) $HEAD_SHA -- config.json || (echo "config.json must not be changed" && exit 1)
CHANGED_PROTOCOLS=$(git diff --name-only $MAIN_SHA $HEAD_SHA -- 'protocols/*' | grep '^protocols/' | xargs -L1 dirname | sed 's|protocols/||' | sort -u)
CHANGED_PROTOCOLS=$CHANGED_PROTOCOLS node validate-config.js