fix(spectral): broaden no-inline-schema rules to all content types #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: OpenAPI Breaking Changes | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'openapi.yaml' | |
| - 'openapi/**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| detect: | |
| name: Detect breaking changes | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout base spec | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.base.sha }} | |
| path: base | |
| - name: Checkout head spec | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| path: head | |
| - name: Install oasdiff | |
| run: | | |
| curl -fsSL https://raw.githubusercontent.com/oasdiff/oasdiff/main/install.sh | sh | |
| - name: Run oasdiff breaking | |
| id: oasdiff | |
| run: | | |
| set +e | |
| oasdiff breaking \ | |
| base/openapi.yaml head/openapi.yaml \ | |
| --format markdown \ | |
| --fail-on ERR > breaking.md | |
| status=$? | |
| echo "status=$status" >> "$GITHUB_OUTPUT" | |
| if [ "$status" -ne 0 ] && [ -s breaking.md ]; then | |
| echo "has_breaking=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_breaking=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build comment body | |
| id: body | |
| if: steps.oasdiff.outputs.has_breaking == 'true' | |
| run: | | |
| { | |
| echo 'body<<COMMENT_EOF' | |
| echo '## :warning: Breaking OpenAPI changes detected' | |
| echo '' | |
| echo 'This PR introduces breaking changes to `openapi.yaml`:' | |
| echo '' | |
| cat breaking.md | |
| echo '' | |
| echo '---' | |
| echo '_Detected by [oasdiff](https://github.com/oasdiff/oasdiff). This PR will need approval from an API reviewer before merge._' | |
| echo 'COMMENT_EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Ensure breaking-change label exists | |
| if: steps.oasdiff.outputs.has_breaking == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| run: | | |
| gh label create "breaking-change" \ | |
| --color B60205 \ | |
| --description "Introduces a breaking change to the OpenAPI spec" \ | |
| 2>/dev/null || true | |
| - name: Add breaking-change label | |
| if: steps.oasdiff.outputs.has_breaking == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: gh pr edit "$PR_NUMBER" --add-label "breaking-change" | |
| - name: Remove breaking-change label if previously set | |
| if: steps.oasdiff.outputs.has_breaking == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: gh pr edit "$PR_NUMBER" --remove-label "breaking-change" || true | |
| - name: Upsert PR comment (breaking) | |
| if: steps.oasdiff.outputs.has_breaking == 'true' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: oasdiff-breaking-changes | |
| message: ${{ steps.body.outputs.body }} | |
| - name: Clear PR comment (no breaking) | |
| if: steps.oasdiff.outputs.has_breaking == 'false' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: oasdiff-breaking-changes | |
| delete: true |