Skip to content

Commit

Permalink
Create validate-json.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnaleem authored Jan 17, 2025
1 parent dab3eb1 commit 3c50a79
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/validate-json.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Validate JSON File

on:
push:
paths:
- 'data.json'
jobs:
validate-json:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Validate JSON structure
run: |
# Validate the JSON file in the root directory
echo "Validating data.json"
jq -e 'map(
.name | type == "string" and
.base_url | type == "string" and
(.url_probe | type == "string" or .url_probe == null) and
.follow_redirects | type == "boolean" and
.errorType | (test("status_code|errorMsg|profilePresence|unknown")) and
(
(.errorType == "errorMsg" and .errorCode == null and .errorMsg | type == "string") or
(.errorType != "errorMsg" and .errorCode | type == "integer" and .errorMsg == null)
)
)' data.json
if [[ $? -ne 0 ]]; then
echo "Validation failed for data.json"
exit 1
fi
shell: bash

0 comments on commit 3c50a79

Please sign in to comment.