Skip to content

Update ja.json (#723) #111

Update ja.json (#723)

Update ja.json (#723) #111

Workflow file for this run

name: Validate JSON Syntax
on:
push:
paths:
- '**.json'
pull_request:
paths:
- '**.json'
jobs:
validate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine changed JSON files
id: changed
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
else
base="${{ github.event.before }}"
head="${{ github.event.after }}"
echo "Attempting to fetch github.event.before = ${{ github.event.before }}"
git fetch origin ${{ github.event.before }} || echo "::warning::Unable to fetch 'before' commit (likely due to force-push)"
fi
echo "Diff base: $base"
echo "Diff head: $head"
files=$(git diff --name-only "$base" "$head" -- '*.json' || true)
echo "files<<EOF" >> "$GITHUB_OUTPUT"
echo "$files" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Validate JSON files
if: steps.changed.outputs.files != ''
shell: "bash {0}"
run: |
failed=0
while read -r file; do
test -f "$file" || continue
jq empty "$file" 2>err.log
if [ $? -ne 0 ]; then
msg=$(<err.log)
# Extract line number from jq error if present
if grep -oE 'at line [0-9]+' err.log >/dev/null; then
lineno=$(grep -oE 'at line [0-9]+' err.log | head -1 | grep -oE '[0-9]+')
echo "::error file=$file,line=$lineno::$msg"
else
echo "::error file=$file::$msg"
fi
failed=1
fi
done <<< "${{ steps.changed.outputs.files }}"
exit $failed