-
Notifications
You must be signed in to change notification settings - Fork 7
54 lines (51 loc) · 1.68 KB
/
validate-oas-files.yml
File metadata and controls
54 lines (51 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Validate OAS Files
on: [pull_request]
jobs:
discover-changed-files:
name: Discover Changed OpenAPI Files
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
has_changes: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v3
- name: Check for changed OAS files
id: changed-files
uses: tj-actions/changed-files@v41
with:
files: |
openapi/**/*.yml
openapi/**/*.yaml
- name: Build matrix from changed files
id: set-matrix
if: steps.changed-files.outputs.any_changed == 'true'
run: |
matrix_json=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq -R -s -c '
split(" ") |
map(select(length > 0)) |
map({
openapi_file: .,
filename: (. | split("/")[-1])
})
')
echo "matrix=${matrix_json}" >> $GITHUB_OUTPUT
echo "Changed files matrix: ${matrix_json}"
validate-openapi:
name: Validate ${{ matrix.filename }}
needs: discover-changed-files
if: needs.discover-changed-files.outputs.has_changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
include: ${{ fromJson(needs.discover-changed-files.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Validate Schema for ${{ matrix.openapi_file }}
uses: thiyagu06/openapi-validator-action@v1
with:
filepath: ${{ matrix.openapi_file }}
- name: Validate YAML for ${{ matrix.openapi_file }}
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: ${{ matrix.openapi_file }}
config_file: .yamllint.yml