forked from redhat-appstudio-qe/strategy-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (44 loc) · 1.28 KB
/
schema_validation.yaml
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
name: Schema validation
on:
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
validate:
name: Validate changed files against JSON schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install yq
run: |
brew install yq
- name: Install jsonschema
run: |
python -m pip install jsonschema
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v21
- name: Validate against JSON schema
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ "$file" == ".github/"* ]] || [[ "$file" != *".yaml" ]]; then
continue
fi
echo -n "Validating file '$file'... "
# yq cannot be piped to pip's jsonschema, so I create a temp file
yq -o json "$file" > "$file".json
jsonschema -i "$file".json .github/schema.json 2> stderr.log || true
rm -rf "$file".json
if [ -s stderr.log ]; then
echo "ERROR"
cat stderr.log
rm stderr.log
exit 1
else
echo "OK"
fi
done