API definition transferred by SwaggerHub #12
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: Provider Design Feedback | |
| # Create/Edit OpenAPI Document in SwaggerHub or store OpenAPI document locally in env.oas_file_location below | |
| # Sync OpenAPI -> SCM with Github Sync - https://support.smartbear.com/swaggerhub/docs/integrations/github-sync.html | |
| # Version number = <OAS Version>-<GitHub Commit SHA>-design | |
| # OpenAPI + Provider Test Report = Provider Contract Uploaded to PactFlow | |
| # *** Test Report is just OAS file, as the design will not be tested against an API mock or real implementation at this stage *** | |
| # PactFlow compares OpenAPI against any registered consumers | |
| # Visiblity into affected consumers visible via can-i-deploy | |
| on: | |
| push: | |
| branches: ['design-candidate*','swaggerhub*', 'main'] | |
| paths: | |
| - 'oas/**' | |
| pull_request: | |
| branches: ['main'] | |
| paths: | |
| - 'oas/**' | |
| workflow_dispatch: | |
| env: | |
| oas_file_location: oas/openapi.yaml | |
| application_name: pactflow-example-provider | |
| PACT_BROKER_BASE_URL: https://vinayma.pactflow.io/ | |
| PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_TOKEN_FOR_CI_CD_WORKSHOP }} | |
| jobs: | |
| pact-publish-oas-action: | |
| # Remove the following condition to run this on your own fork | |
| # This workflow is disabled by default to allow users to run the Consumer-Driven Contract | |
| # testing workshop without distraction. By removing the condition, this workflow will | |
| # upload an OpenAPI Design candidate showcasing Bi-Directional Contract testing | |
| # working alongside Bi-Directional Contract Testing | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: get version of OAS | |
| run: | | |
| sudo snap install yq | |
| UNIQUE_VERSION=$(yq '.info.version' ${{ env.oas_file_location }})-${{ github.sha }}-design | |
| echo "version=${UNIQUE_VERSION}" >> $GITHUB_ENV | |
| - name: publishing ${{ env.application_name }} with ${{ env.version }} to PactFlow | |
| uses: pactflow/actions/[email protected] | |
| env: | |
| oas_file: ${{ env.oas_file_location }} | |
| results_file: ${{ env.oas_file_location }} | |
| outputs: | |
| version: ${{ env.version }} | |
| pact-can-i-deploy: | |
| strategy: | |
| matrix: | |
| environment: [test, production] | |
| fail-fast: false | |
| needs: pact-publish-oas-action | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: can-i-deploy ${{ env.application_name }} to ${{ matrix.environment }} | |
| uses: pactflow/actions/[email protected] | |
| env: | |
| to_environment: ${{ matrix.environment }} | |
| version: ${{ needs.pact-publish-oas-action.outputs.version }} |