Skip to content

Commit 672e89d

Browse files
fix(ci): use matrix and validator action
1 parent 0b34195 commit 672e89d

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

.github/workflows/validate-schemas.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,41 @@ on:
1313
- '.schemas/**/*.json'
1414

1515
jobs:
16-
validate:
16+
prepare:
1717
runs-on: ubuntu-latest
18+
outputs:
19+
matrix: ${{ steps.set-matrix.outputs.matrix }}
1820
steps:
1921
- uses: actions/checkout@v4
2022

21-
- name: Setup Node.js
22-
uses: actions/setup-node@v4
23-
with:
24-
node-version: '20'
25-
26-
- name: Install ajv-cli
27-
run: npm install -g ajv-cli
28-
29-
- name: Validate JSON Schemas
23+
- id: set-matrix
3024
run: |
31-
# First validate that our schema files are valid JSON Schema
32-
for schema in .schemas/*.json; do
33-
echo "Validating schema file: $schema"
34-
ajv compile -s http://json-schema.org/draft-07/schema -c $schema
25+
PROJECTS=$(ls -d */ | grep -v '.git\|.github\|.schemas\|.vscode' | sed 's#/##')
26+
CONFIGS=("development" "hosting")
27+
MATRIX="{\"include\":["
28+
FIRST=true
29+
for project in $PROJECTS; do
30+
for config in "${CONFIGS[@]}"; do
31+
if [ "$FIRST" = true ]; then
32+
FIRST=false
33+
else
34+
MATRIX+=","
35+
fi
36+
MATRIX+="{\"project\":\"$project\",\"config\":\"$config\"}"
37+
done
3538
done
39+
MATRIX+="]}"
40+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
3641
37-
- name: Validate YAML Files
38-
run: |
39-
# Install yaml parsing tools
40-
npm install -g yaml-validator
41-
42-
# Validate development.yaml files against schema
43-
for file in **/development.yaml; do
44-
echo "Validating: $file"
45-
yaml-validator -s .schemas/development.json $file
46-
done
42+
validate:
43+
needs: prepare
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
47+
steps:
48+
- uses: actions/checkout@v4
4749

48-
# Validate hosting.yaml files against schema
49-
for file in **/hosting.yaml; do
50-
echo "Validating: $file"
51-
yaml-validator -s .schemas/hosting.json $file
52-
done
50+
- uses: nrkno/yaml-schema-validator-github-action@v5
51+
with:
52+
schema: .schemas/${{ matrix.config }}.json
53+
target: ${{ matrix.project }}/${{ matrix.config }}.yaml

0 commit comments

Comments
 (0)