|
13 | 13 | - '.schemas/**/*.json' |
14 | 14 |
|
15 | 15 | jobs: |
16 | | - validate: |
| 16 | + prepare: |
17 | 17 | runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
18 | 20 | steps: |
19 | 21 | - uses: actions/checkout@v4 |
20 | 22 |
|
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 |
30 | 24 | 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 |
35 | 38 | done |
| 39 | + MATRIX+="]}" |
| 40 | + echo "matrix=$MATRIX" >> $GITHUB_OUTPUT |
36 | 41 |
|
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 |
47 | 49 |
|
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