From d2528b178390a83d2518699b579fd60f7ddcac41 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 14:42:20 +0100 Subject: [PATCH 1/8] CLOUDP-269114: Change release postman trigger --- .github/workflows/release-postman.yml | 7 +------ .github/workflows/release-spec.yml | 4 ++++ tools/postman/collection-description.md | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-postman.yml b/.github/workflows/release-postman.yml index 43caad583..9a26e73d9 100644 --- a/.github/workflows/release-postman.yml +++ b/.github/workflows/release-postman.yml @@ -1,17 +1,12 @@ name: Postman Release on: - pull_request: - branches: - - main - types: - - closed + workflow_call: workflow_dispatch: permissions: issues: write jobs: release-postman: - if: ${{ github.head_ref == 'api-bot-update' && github.event.pull_request.merged }} runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index aa3a42b90..d07570c86 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -149,3 +149,7 @@ jobs: title: "(${{env.target_env}}) Release: the Commit Changes step failed :scream_cat:" body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} token: ${{ secrets.GITHUB_TOKEN }} + - name: Release Postman + if: ${{ inputs.env == 'Prod' && steps.commit.outputs.changes_detected == 'true' }} + uses: ./.github/workflows/release-postman.yml + diff --git a/tools/postman/collection-description.md b/tools/postman/collection-description.md index 67a56807f..d2164c7b4 100644 --- a/tools/postman/collection-description.md +++ b/tools/postman/collection-description.md @@ -12,4 +12,6 @@ Once you have your cluster up and running, follow [this guide](https://www.mongo - public API key as the value for a key named \`mongodb-public-api-key\` - private API key as the value for a key named \`mongodb-private-api-key\` -You can now explore the various endpoints. For each endpoint, edit the query and path variables such as group ID and organization ID. For some requests, like POST requests, editing the body of the request is also required. \ No newline at end of file +You can now explore the various endpoints. For each endpoint, edit the query and path variables such as group ID and organization ID. For some requests, like POST requests, editing the body of the request is also required. + +For more details, you can follow along with the [Configuring Atlas in Postman With the Atlas Administration API](https://www.mongodb.com/developer/products/atlas/admin-api-postman/) blog. \ No newline at end of file From dbda38f0be8e2e49bf85b8964472b8fa60292c65 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 15:41:06 +0100 Subject: [PATCH 2/8] CLOUDP-269114: Explictly pass secrets and vars --- .github/workflows/release-postman.yml | 16 +++++++++++++++- .github/workflows/release-spec-runner.yml | 3 +++ .github/workflows/release-spec.yml | 16 ++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-postman.yml b/.github/workflows/release-postman.yml index 9a26e73d9..9e43bb7cc 100644 --- a/.github/workflows/release-postman.yml +++ b/.github/workflows/release-postman.yml @@ -1,6 +1,20 @@ name: Postman Release on: workflow_call: + inputs: + spectral_version: + description: 'Version of Spectral to use.' + required: true + type: string + atlas_prod_base_url: + description: 'Base URL of Atlas.' + required: true + type: string + secrets: # all secrets are passed explicitly in this workflow + postman_api_key: + required: true + workspace_id: + required: true workflow_dispatch: permissions: issues: write @@ -35,7 +49,7 @@ jobs: - name: Transform Postman Collection id: transform env: - BASE_URL: ${{ vars.ATLAS_PROD_BASE_URL }} + BASE_URL: ${{ inputs.atlas_prod_base_url }} working-directory: ./tools/postman run: | make transform_collection diff --git a/.github/workflows/release-spec-runner.yml b/.github/workflows/release-spec-runner.yml index 90daa4cb2..472526bb6 100644 --- a/.github/workflows/release-spec-runner.yml +++ b/.github/workflows/release-spec-runner.yml @@ -58,6 +58,8 @@ jobs: api_bot_pat: ${{ secrets.API_BOT_PAT }} aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }} aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }} + postman_api_key: ${{ secrets.POSTMAN_API_KEY }} + workspace_id: ${{ secrets.WORKSPACE_ID }} with: aws_default_region: ${{ vars.AWS_DEFAULT_REGION}} aws_s3_bucket: ${{ vars.S3_BUCKET_PROD}} @@ -65,3 +67,4 @@ jobs: branch: main spectral_version: ${{ vars.SPECTRAL_VERSION }} foascli_version: ${{ vars.FOASCLI_VERSION }} + atlas_prod_base_url: ${{ vars.ATLAS_PROD_BASE_URL }} diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index d07570c86..21bb8a6ed 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -26,6 +26,10 @@ on: description: 'Version of FOASCLI to use.' required: true type: string + atlas_prod_base_url: + description: 'Base URL of Atlas.' + required: false + type: string secrets: # all secrets are passed explicitly in this workflow api_bot_pat: required: true @@ -33,7 +37,11 @@ on: required: true aws_secret_access_key: required: true - + postman_api_key: + required: false + workspace_id: + required: false + permissions: contents: write issues: write @@ -152,4 +160,8 @@ jobs: - name: Release Postman if: ${{ inputs.env == 'Prod' && steps.commit.outputs.changes_detected == 'true' }} uses: ./.github/workflows/release-postman.yml - + secrets: + postman_api_key: ${{ secrets.postman_api_key }} + workspace_id: ${{ secrets.workspace_id }} + with: + spectral_version: ${{ inputs.spectral_version }} From 76485a7c6668e1c83c674de45b2690a3c6e541a1 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 16:19:50 +0100 Subject: [PATCH 3/8] CLOUDP-269114: Add atlas_prod_base_url parameter --- .github/workflows/release-spec.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index 21bb8a6ed..f95a9a20f 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -165,3 +165,4 @@ jobs: workspace_id: ${{ secrets.workspace_id }} with: spectral_version: ${{ inputs.spectral_version }} + atlas_prod_base_url: ${{ inputs.atlas_prod_base_url}} From ef22471189f90712dcd0a263c4211035dc5b5b59 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 16:46:10 +0100 Subject: [PATCH 4/8] CLOUDP-269114: Change release postman from step to job --- .github/workflows/release-spec.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index f95a9a20f..372cad059 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -85,6 +85,8 @@ jobs: name: Release OpenAPI Spec runs-on: ubuntu-latest needs: [run-required-validations] + outputs: + changes_detected: ${{ steps.commit.outputs.changes_detected }} steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -157,12 +159,16 @@ jobs: title: "(${{env.target_env}}) Release: the Commit Changes step failed :scream_cat:" body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} token: ${{ secrets.GITHUB_TOKEN }} - - name: Release Postman - if: ${{ inputs.env == 'Prod' && steps.commit.outputs.changes_detected == 'true' }} - uses: ./.github/workflows/release-postman.yml - secrets: - postman_api_key: ${{ secrets.postman_api_key }} - workspace_id: ${{ secrets.workspace_id }} - with: - spectral_version: ${{ inputs.spectral_version }} - atlas_prod_base_url: ${{ inputs.atlas_prod_base_url}} + + release-postman: + name: Release Postman + runs-on: ubuntu-latest + needs: [release] + if: ${{ inputs.env == 'Prod' && needs.release.outputs.changes_detected == 'true' }} + uses: ./.github/workflows/release-postman.yml + secrets: + postman_api_key: ${{ secrets.postman_api_key }} + workspace_id: ${{ secrets.workspace_id }} + with: + spectral_version: ${{ inputs.spectral_version }} + atlas_prod_base_url: ${{ inputs.atlas_prod_base_url}} From d5af154b6739349741bfe372e75c6115f9196549 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 16:48:23 +0100 Subject: [PATCH 5/8] CLOUDP-269114: Lint --- .github/workflows/release-spec.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index 372cad059..59568c21f 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -162,7 +162,6 @@ jobs: release-postman: name: Release Postman - runs-on: ubuntu-latest needs: [release] if: ${{ inputs.env == 'Prod' && needs.release.outputs.changes_detected == 'true' }} uses: ./.github/workflows/release-postman.yml From 6dab8449ae79a6f4044e01ddb8c22110b72b97bd Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 16:54:35 +0100 Subject: [PATCH 6/8] CLOUDP-269114: Remove spectral version as input to postman workflow --- .github/workflows/release-postman.yml | 8 ++------ .github/workflows/release-spec.yml | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-postman.yml b/.github/workflows/release-postman.yml index 9e43bb7cc..3770396ef 100644 --- a/.github/workflows/release-postman.yml +++ b/.github/workflows/release-postman.yml @@ -2,10 +2,6 @@ name: Postman Release on: workflow_call: inputs: - spectral_version: - description: 'Version of Spectral to use.' - required: true - type: string atlas_prod_base_url: description: 'Base URL of Atlas.' required: true @@ -65,8 +61,8 @@ jobs: - name: Upload Collection to Postman env: - POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }} - WORKSPACE_ID: ${{ secrets.WORKSPACE_ID }} + POSTMAN_API_KEY: ${{ secrets.postman_api_key }} + WORKSPACE_ID: ${{ secrets.postman_api_key }} working-directory: ./tools/postman run: | make upload_collection diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index 59568c21f..c65044eaf 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -169,5 +169,4 @@ jobs: postman_api_key: ${{ secrets.postman_api_key }} workspace_id: ${{ secrets.workspace_id }} with: - spectral_version: ${{ inputs.spectral_version }} atlas_prod_base_url: ${{ inputs.atlas_prod_base_url}} From 6ce6d7dcf0047e6dc8622398a09cd13876b5db4f Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Wed, 21 Aug 2024 16:55:46 +0100 Subject: [PATCH 7/8] CLOUDP-269114: Correct workspace_id secret name --- .github/workflows/release-postman.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-postman.yml b/.github/workflows/release-postman.yml index 3770396ef..800b41977 100644 --- a/.github/workflows/release-postman.yml +++ b/.github/workflows/release-postman.yml @@ -62,7 +62,7 @@ jobs: - name: Upload Collection to Postman env: POSTMAN_API_KEY: ${{ secrets.postman_api_key }} - WORKSPACE_ID: ${{ secrets.postman_api_key }} + WORKSPACE_ID: ${{ secrets.workspace_id }} working-directory: ./tools/postman run: | make upload_collection From a0e61ecfc74c7b7c78e72ed83d01f827c4039276 Mon Sep 17 00:00:00 2001 From: Luke Sanderson <94322623+Luke-Sanderson@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:31:41 +0100 Subject: [PATCH 8/8] Update Prod to prod Co-authored-by: Andrea Angiolillo --- .github/workflows/release-spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index c65044eaf..6eda88e3f 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -163,7 +163,7 @@ jobs: release-postman: name: Release Postman needs: [release] - if: ${{ inputs.env == 'Prod' && needs.release.outputs.changes_detected == 'true' }} + if: ${{ inputs.env == 'prod' && needs.release.outputs.changes_detected == 'true' }} uses: ./.github/workflows/release-postman.yml secrets: postman_api_key: ${{ secrets.postman_api_key }}