-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (67 loc) · 2.13 KB
/
validation.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
73
74
75
76
77
78
79
80
81
82
83
name: Validation
on:
pull_request:
push:
branches:
- main
- develop
jobs:
json_validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for new or modified JSON project files
id: check_files
run: |
JSON_COUNT=$(git diff --name-only HEAD^..HEAD | grep -c "content/projects/.*\.json" || true)
echo "::set-output name=count::$JSON_COUNT"
- name: Configure Node 16
if: steps.check_files.outputs.count != '0'
uses: actions/setup-node@v2
with:
node-version: 16
- name: Cache npm dependencies
if: steps.check_files.outputs.count != '0'
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
if: steps.check_files.outputs.count != '0'
run: npm ci
- name: Set script permissions
if: steps.check_files.outputs.count != '0'
run: chmod +x ./scripts/basic-validation.sh
- name: Validate JSON files
if: steps.check_files.outputs.count != '0'
run: ./scripts/basic-validation.sh
schema_validation:
needs: json_validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if JSON files are modified
id: check_files
run: |
JSON_COUNT=$(git diff --name-only HEAD^..HEAD | grep -c "content/projects/.*\.json" || true)
echo "::set-output name=count::$JSON_COUNT"
- name: Configure Node 16
if: steps.check_files.outputs.count != '0'
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install NPM dependencies
if: steps.check_files.outputs.count != '0'
run: npm ci
- name: Set script permissions
if: steps.check_files.outputs.count != '0'
run: chmod +x ./scripts/schema-validation.sh
- name: Validate JSON schema
if: steps.check_files.outputs.count != '0'
run: ./scripts/schema-validation.sh