diff --git a/.github/workflows/push-collection-to-postman.yml b/.github/workflows/push-collection-to-postman.yml index 0330251e..36d9039d 100644 --- a/.github/workflows/push-collection-to-postman.yml +++ b/.github/workflows/push-collection-to-postman.yml @@ -1,45 +1,90 @@ -name: Push collection to Postman workspace +name: Push Postman collection changes to public collection +# This workflow pushes any changes to the Postman collections in the repo to the Postman collections within the +# Validated Relationships Service workspace. +# This means that all changes and version control are handled within GitHub for the collections and only once the +# changes have been merged are the public-facing Postman collections updated. +# Please see updated instructions on Confluence for further details about how this workflow fits into that process. on: workflow_dispatch: inputs: - collection: - type: choice - description: Collection to push - options: - - sandbox - - integration - required: true - default: sandbox - - workflow_call: - inputs: - collection: - type: string - description: Collection to push - required: true + should_push_sandbox: + type: boolean + description: Push Sandbox collection + default: false + should_push_integration: + type: boolean + description: Push Integration collection + default: false + push: + branches: + - master + paths: + - './postman/validated_relationship_service.**' jobs: - push-to-postman: - name: Push collection to Postman + detect-changes: + name: Detect which Postman collection has changed + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} + outputs: + sandbox: ${{ steps.filter.outputs.sandbox }} + integration: ${{ steps.filter.outputs.integration }} + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + sandbox: + - './postman/validated_relationship_service.sandbox.postman_collection.json' + integration: + - './postman/validated_relationship_service.integration.postman_collection.json' + + push-sandbox-postman: + name: Push Sandbox collection to Postman runs-on: ubuntu-latest + needs: [detect-changes] + if: | + always () && ( + (github.event_name == 'push' && needs.detect-changes.outputs.sandbox == 'true') || + (github.event_name == 'workflow_dispatch' && github.event.inputs.should_push_sandbox == 'true') + ) steps: - name: Checkout uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Get collection ID - id: get_collection_id - run: | - if [[ '${{ github.event.inputs.collection }}' == 'sandbox' ]]; then - echo 'collection_id=${{ secrets.POSTMAN_SANDBOX_COLLECTION_ID }}' >> $GITHUB_OUTPUT - else - echo 'collection_id=${{ secrets.POSTMAN_INTEGRATION_COLLECTION_ID }}' >> $GITHUB_OUTPUT - fi - - name: push-to-postman-action - id: process + - name: Push Sandbox Postman collection + id: push_sandbox_postman_collection uses: gcatanese/push-to-postman-action@main with: goal: update postman-key: ${{ secrets.POSTMAN_API_KEY }} - postman-file: '/postman/validated_relationship_service.${{ github.event.inputs.collection }}.postman_collection.json' - collection-id: ${{ steps.get_collection_id.outputs.collectionId }} + postman-file: './postman/validated_relationship_service.sandbox.postman_collection.json' + collection-id: ${{ secrets.POSTMAN_SANDBOX_COLLECTION_ID }} + + push-integration-postman: + name: Push Integration collection to Postman + runs-on: ubuntu-latest + needs: [detect-changes] + if: | + always () && ( + (github.event_name == 'push' && needs.detect-changes.outputs.integration == 'true') || + (github.event_name == 'workflow_dispatch' && github.event.inputs.should_push_integration == 'true') + ) + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Push Integration Postman collection + id: push_integration_postman_collection + uses: gcatanese/push-to-postman-action@main + with: + goal: update + postman-key: ${{ secrets.POSTMAN_API_KEY }} + postman-file: './postman/validated_relationship_service.integration.postman_collection.json' + collection-id: ${{ secrets.POSTMAN_INTEGRATION_COLLECTION_ID }} diff --git a/postman/validated_relationship_service.sandbox.postman_collection.json b/postman/validated_relationship_service.sandbox.postman_collection.json index 00116c35..a45bb35b 100644 --- a/postman/validated_relationship_service.sandbox.postman_collection.json +++ b/postman/validated_relationship_service.sandbox.postman_collection.json @@ -11052,11 +11052,6 @@ { "key": "api_base_url", "value": "https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4" - }, - { - "value": "", - "type": "string", - "disabled": true } ] -} \ No newline at end of file +}