Skip to content

Add GH action: convert yaml to json #9

Add GH action: convert yaml to json

Add GH action: convert yaml to json #9

Workflow file for this run

name: validate-json
on:
workflow_call:
inputs:
should_download:
description: "Download JSON artifacts if called by another workflow?"
type: boolean
outputs:
is_valid:
description: "Is the JSON valid?"
value: ${{ jobs.validate.outputs.is_valid}}
pull_request:
branches: ["*"]
workflow_dispatch:
jobs:
validate:
runs-on: ubuntu-latest
outputs:
is_valid: ${{ steps.save_state.outputs.is_valid}}
steps:
- uses: actions/checkout@v4
- name: Download JSON artifacts # if called by another workflow
if: ${{ inputs.should_download }}
uses: actions/download-artifact@v4
with:
name: json-files
path: json
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.22.4"
- name: Install dependencies
run: go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest
- name: Validate JSON files
id: validate_json
run: |
if [ -d "json" ] && [ "$(ls -A json/*.json 2>/dev/null)" ]; then
jv schema.json json/*.json
else
echo "No JSON files to process."
fi
- name: Save state
id: save_state
if: steps.validate_json.conclusion == 'success'
run: echo "is_valid=true" >> $GITHUB_OUTPUT