Reviewed-on: #1 Co-authored-by: Timo Behrendt <t.behrendt@t00n.de> Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #1.
This commit is contained in:
35
action.yml
Normal file
35
action.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
- shell: bash
|
||||
run: npm ci
|
||||
- name: Extract schema
|
||||
shell: bash
|
||||
run: |
|
||||
schema=$(jq -r '.["$schema"]' < ${{ inputs.json-file }})
|
||||
if [ -n "$schema" ]; then
|
||||
curl -s $schema > schema.json
|
||||
else
|
||||
echo "No schema found"
|
||||
exit 0
|
||||
fi
|
||||
- name: Update the schema to the latest version
|
||||
shell: bash
|
||||
run: |
|
||||
npx ajv-cli migrate -s schema.json -o schema.json
|
||||
- name: Validate JSON
|
||||
shell: bash
|
||||
run: |
|
||||
npx ajv-cli validate -s schema.json -d ${{ inputs.json-file }} --strict=false
|
||||
Reference in New Issue
Block a user