-
Notifications
You must be signed in to change notification settings - Fork 24
51 lines (43 loc) · 1.17 KB
/
validate-scripts.yml
File metadata and controls
51 lines (43 loc) · 1.17 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
name: Validate Sample Scripts
on:
push:
branches: [main]
paths:
- 'samples/**/*.json'
- 'templates/**/*.json'
pull_request:
branches: [main]
paths:
- 'samples/**/*.json'
- 'templates/**/*.json'
jobs:
validate-json:
name: JSON Syntax Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate JSON files
run: |
failed=0
found=0
for dir in samples templates; do
while IFS= read -r -d '' f; do
found=1
if ! jq empty "$f" >/dev/null 2>&1; then
echo "::error file=$f::Invalid JSON syntax"
echo "FAILED: $f"
jq empty "$f"
failed=1
fi
done < <(find "$dir" -type f -name '*.json' -print0)
done
if [ "$found" -eq 0 ]; then
echo "No JSON files found under samples/ or templates/."
exit 0
fi
if [ "$failed" -ne 0 ]; then
echo
echo "One or more JSON files failed validation."
exit 1
fi
echo "All JSON files are valid."