This Github Action runs openapitools/openapi-diff on two versions of an OpenAPI spec.
It provides feedback on whether the changes are one of:
- no_changes
- incompatible
- compatible
It also provides a Markdown file that contains a readable version of the diff produced by openapitools/openapi-diff.
- Required
service-name
: Name of the (micro) service that owns/implements the OpenAPI spec. This is tacked onto the name of the HTML output file for easy consumption. - Required
new-openapi-spec
: Path to the new version of the OpenAPI spec. Relative to${{ github_workspace }}
and usually repo checked out at${{ github_head_ref }}
- Required
current-openapi-spec
: Path to the current version of the OpenAPI spec. Relative to${{ github_workspace }}
and usually repo checked out at${{ github_base_ref }}
diff-state
: One word summary of the diff and one of:no_changes, incompatible, compatible
. Can be used to conditionally execute some flows based on the result of the diff.diff-md-result
: The diff generated by openapitools/openapi-diff in a Markdown file. Created in${{ github_workspace }}
and the name is of the format$(service-name)-openapi-diff.md
...
steps:
- name: Checkout head
uses: actions/checkout@v2
with:
fetch-depth: 0
path: head
- name: Checkout base
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
path: base
- name: OpenAPI diff run
uses: nareshbaliga/openapi-diff-gh-action@master
id: oad
with:
service-name: my-service-name
new-openapi-spec: head/apis/my-service-name-api/v2/api.yaml
current-openapi-spec: base/apis/my-service-name-api/v2/api.yaml
- name: OpenAPI diff upload results
uses: actions/upload-artifact@v2
with:
path: ./${{ steps.oad.outputs.diff-md-result }}
name: ${{ steps.oad.outputs.diff-md-result }}
- name: OpenAPI diff breaking changes check
if: steps.oad.outputs.diff-state == 'incompatible'
uses: actions/github-script@v5
with:
script: |
core.setFailed('Breaking OpenAPI changes found!')
...