Skip to content

Commit e84cdb1

Browse files
Add CI workflow to validate JSON files on push and PR (#1)
* Add GitHub Actions workflow to validate JSON files on PRs Agent-Logs-Url: https://github.com/GroundServicesJP/GroundServicesJP_JSONService/sessions/fcd8c8bf-d92b-4c3e-a9d2-197984bffb63 Co-authored-by: anaflightsim <66984894+anaflightsim@users.noreply.github.com> * Trigger JSON validation on push to all branches in addition to pull requests Agent-Logs-Url: https://github.com/GroundServicesJP/GroundServicesJP_JSONService/sessions/ce4b38a4-acdf-46f0-9406-73d44a150cb7 Co-authored-by: anaflightsim <66984894+anaflightsim@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: anaflightsim <66984894+anaflightsim@users.noreply.github.com>
1 parent 56f084d commit e84cdb1

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Validate JSON
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
validate-json:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Validate JSON files
18+
run: |
19+
failed=0
20+
passed=0
21+
while IFS= read -r -d '' file; do
22+
if ! python3 -m json.tool "$file" > /dev/null 2>&1; then
23+
echo "❌ Invalid JSON: $file"
24+
python3 -m json.tool "$file" 2>&1 || true
25+
failed=$((failed + 1))
26+
else
27+
echo "✅ Valid JSON: $file"
28+
passed=$((passed + 1))
29+
fi
30+
done < <(find . -name '*.json' -not -path './.git/*' -print0)
31+
32+
echo ""
33+
echo "Results: $passed passed, $failed failed"
34+
if [ "$failed" -ne 0 ]; then
35+
echo "::error::$failed JSON file(s) failed validation. See above for details."
36+
exit 1
37+
fi

0 commit comments

Comments
 (0)