2022-05-09 07:47:54 +08:00
|
|
|
name: Json Validator
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
2023-06-04 02:24:27 +08:00
|
|
|
paths:
|
|
|
|
- '**.json'
|
2022-05-09 07:47:54 +08:00
|
|
|
push:
|
2022-05-25 21:35:36 +08:00
|
|
|
branches:
|
|
|
|
- main
|
2023-06-04 02:24:27 +08:00
|
|
|
paths:
|
|
|
|
- '**.json'
|
2022-05-09 07:47:54 +08:00
|
|
|
|
|
|
|
jobs:
|
2023-06-06 16:28:19 +08:00
|
|
|
json-validator:
|
2022-05-09 07:47:54 +08:00
|
|
|
name: Json Validator
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2023-09-04 20:29:01 +08:00
|
|
|
uses: actions/checkout@v4
|
2022-05-09 07:47:54 +08:00
|
|
|
- name: Validate Json
|
|
|
|
run: |
|
2023-06-06 16:30:32 +08:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install python3-pip -y --no-install-recommends
|
2022-05-09 07:47:54 +08:00
|
|
|
sudo pip3 install json-spec
|
2023-09-30 04:24:00 +08:00
|
|
|
if ! json validate --schema-file=php/containers-schema.json --document-file=php/containers.json; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-05-31 18:00:44 +08:00
|
|
|
JSON_FILES="$(find ./community-containers -name '*.json')"
|
|
|
|
mapfile -t JSON_FILES <<< "$JSON_FILES"
|
|
|
|
for file in "${JSON_FILES[@]}"; do
|
2023-09-30 04:24:00 +08:00
|
|
|
json validate --schema-file=php/containers-schema.json --document-file="$file" 2>&1 | tee -a ./json-validator.log
|
2023-05-31 18:00:44 +08:00
|
|
|
done
|
2023-09-30 04:24:00 +08:00
|
|
|
if grep -q "document does not validate with schema." ./json-validator.log; then
|
2023-05-31 18:00:44 +08:00
|
|
|
exit 1
|
|
|
|
fi
|