Files
validate-json-by-json-schem…/action.yml
Timo Behrendt 02b5a3524e
All checks were successful
CI / Dry-Run (pull_request) Successful in 18s
set strict mode to false
2025-10-03 16:51:45 +02:00

34 lines
973 B
YAML

name: "Validate JSON by JSON Schema"
description: "Validates JSON files using their $schema reference"
author: "Timo Behrendt <t.behrendt@t00n.de>"
inputs:
json-file:
description: "The JSON file to validate"
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-node@v5
- name: Extract schema
shell: bash
run: |
echo "Extracting schema from ${{ inputs.json-file }}"
schema=$(jq -r '.["$schema"]' < ${{ inputs.json-file }})
if [ -n "$schema" ]; then
curl -s $schema > schema.json
else
exit 0
fi
- name: Update the schema to the latest version
shell: bash
run: |
echo "Updating schema to the latest version"
npx ajv-cli migrate -s schema.json -o schema.json
- name: Validate JSON
shell: bash
run: |
echo "Validating JSON"
npx ajv-cli validate -s schema.json -d ${{ inputs.json-file }} --strict=false