File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ name : Validate JSON syntax
3+
4+ # Run on any commit or PR that changes any JSON file.
5+ ' on ' :
6+ push :
7+ paths :
8+ - ' **.json'
9+ pull_request :
10+ paths :
11+ - ' **.json'
12+
13+ permissions : {}
14+
15+ jobs :
16+ json-syntax :
17+ name : validate syntax
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - name : Checkout code
22+ uses : actions/checkout@v4
23+
24+ - name : Validate syntax for JSON files
25+ run : |
26+ error=0
27+ readarray -d '' json_files < \
28+ <(find . \( -path ./.git -or -path ./DATA/testing/private \) -prune -false -or -type f -name '*.json' -print0)
29+ for jsonf in "${json_files[@]}"; do
30+ echo "::debug::Checking $jsonf..."
31+ if ! errmsg=$(jq . "$jsonf" 2>&1 >/dev/null); then
32+ error=1
33+ echo "Invalid JSON syntax found in $jsonf:" >&2
34+ printf '::error file=%s,title=%s::%s\n' "$jsonf" 'Invalid JSON syntax' "$errmsg"
35+ fi
36+ done
37+ exit "$error"
You can’t perform that action at this time.
0 commit comments