Skip to content

Enable versioned-sdk-dispatch for real dispatch #4

Enable versioned-sdk-dispatch for real dispatch

Enable versioned-sdk-dispatch for real dispatch #4

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