Files
validate-json-by-json-schem…/action.yml
Timo Behrendt 648ffb0717
Some checks failed
CI / Dry-Run (pull_request) Failing after 6s
drop comments
2025-10-03 14:01:39 +02:00

30 lines
770 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:
- name: Extract schema
shell: bash
run: |
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: |
npx ajv migrate -i schema.json -o schema.json
- name: Validate JSON
shell: bash
run: |
npx ajv validate -s schema.json -d ${{ inputs.json-file }}