From ab1efe69f2da09192d6a1605c0a1a8bb192729d7 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Thu, 21 Sep 2023 09:38:00 +0200 Subject: [PATCH] Update validate_database_json.yml --- .github/workflows/validate_database_json.yml | 40 ++++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/validate_database_json.yml b/.github/workflows/validate_database_json.yml index c65ac30..9b37491 100644 --- a/.github/workflows/validate_database_json.yml +++ b/.github/workflows/validate_database_json.yml @@ -1,11 +1,11 @@ -name: Validate JSONs +name: Validate JSON on: workflow_call: - inputs: - FILENAME: - required: true - type: string + inputs: + FILENAME: + required: true + type: string workflow_dispatch: inputs: @@ -14,14 +14,30 @@ on: type: string jobs: - verify-json-validation: + validate-json: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v2 with: - path: fts3-databases + path: fts3-databases + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' # Use the Node.js version you prefer + + - name: Install dependencies + run: npm install ajv-cli + - name: Validate JSON - uses: docker://orrosenblatt/validate-json-action:latest - env: - INPUT_SCHEMA: ./fts3-databases/databases/database_schema.json - INPUT_JSONS: ./fts3-databases/databases/${{ inputs.FILENAME || github.event.inputs.FILENAME }}" + run: | + FILENAME="./fts3-databases/databases/${{ inputs.FILENAME || github.event.inputs.FILENAME }}" + SCHEMA="./fts3-databases/databases/database_schema.json" + + if npx ajv -s "$SCHEMA" -d "$FILENAME"; then + echo "JSON is valid." + else + echo "JSON is invalid." + exit 1 + fi