From fd9e754e8d10234e622b133f70bd38fbe8482076 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Tue, 10 Jun 2025 14:45:20 +0200 Subject: [PATCH 01/10] CLOUDP-323790: Update foas release process to support bump.sh deployment for all the envs --- .github/scripts/generateSpecMapping.js | 2 +- .github/workflows/generate-bump-pages.yml | 98 +++++++++++++---------- .github/workflows/release-spec-runner.yml | 12 +++ .github/workflows/release-spec.yml | 24 ++++++ 4 files changed, 94 insertions(+), 42 deletions(-) diff --git a/.github/scripts/generateSpecMapping.js b/.github/scripts/generateSpecMapping.js index 8c888623a7..a136906ada 100644 --- a/.github/scripts/generateSpecMapping.js +++ b/.github/scripts/generateSpecMapping.js @@ -12,7 +12,7 @@ const SPEC_MAPPING = [ { doc: process.env.ATLAS_ADMIN_V1_DOC_ID, file: 'openapi/v1-deprecated/v1.json', - branch: 'main', + branch: process.env.BRANCH_NAME }, ]; diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index db920ca28e..7448afc05c 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -1,20 +1,28 @@ -name: Check & deploy API documentation - +name: Release the OpenAPI spec to Bump.sh on: - # For deployments - workflow_dispatch: # Allow manual trigger in case of quick fix - push: - branches: - - main - paths: - - 'openapi/**.json' - - # For previews - pull_request: - branches: - - main - paths: - - 'openapi/**.json' + workflow_call: + inputs: + env: + description: 'Environment to release the OpenAPI Spec to.' + required: true + type: string + atlas_admin_v1_doc_id: + description: 'Bump Doc ID for the v1 spec' + required: true + type: string + atlas_admin_v2_doc_id: + description: 'Bump Doc ID for the v2 specs' + required: true + type: string + branch: + description: 'Branch to release the OpenAPI Spec to.' + required: true + type: string + secrets: + api_bot_pat: + required: true + bump_token: + required: true permissions: contents: read @@ -27,52 +35,60 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + token: ${{secrets.api_bot_pat}} - name: Setup Node uses: actions/setup-node@v4 - name: Generate matrix id: set-matrix env: - ATLAS_ADMIN_V1_DOC_ID: ${{ vars.ATLAS_ADMIN_V1_DOC_ID }} - ATLAS_ADMIN_V2_DOC_ID: ${{ vars.ATLAS_ADMIN_V2_DOC_ID }} + ATLAS_ADMIN_V1_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} + ATLAS_ADMIN_V2_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} + BRANCH_NAME: ${{ inputs.branch }} run: | spec_mapping=$(node .github/scripts/generateSpecMapping.js) echo "matrix=$spec_mapping" >> "$GITHUB_OUTPUT" deploy-doc: needs: create-matrix - if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} name: Deploy API documentation on Bump.sh strategy: matrix: spec-mapping: ${{ fromJson(needs.create-matrix.outputs.matrix) }} runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - - name: Deploy API documentation - uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c with: - doc: ${{matrix.spec-mapping.doc}} - token: ${{secrets.BUMP_TOKEN}} - file: ${{matrix.spec-mapping.file}} - branch: ${{matrix.spec-mapping.branch}} - - api-preview: - needs: create-matrix - if: ${{ github.event_name == 'pull_request' }} - name: Create API preview on Bump.sh - strategy: - matrix: - spec-mapping: ${{ fromJSON(needs.create-matrix.outputs.matrix) }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Create API preview + ref: ${{ inputs.branch }} + token: ${{secrets.api_bot_pat}} + - name: Deploy API documentation - PROD uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c with: doc: ${{matrix.spec-mapping.doc}} - token: ${{secrets.BUMP_TOKEN}} + token: ${{secrets.bump_token}} file: ${{matrix.spec-mapping.file}} branch: ${{matrix.spec-mapping.branch}} - command: preview + +# We don't need to preview the API since the PR is autogenerated and always merge into master +# we will migrate this logic to another workflow that can be trigger ondemand by adding a label to a PR. +# api-preview: +# needs: create-matrix +# if: ${{ github.event_name == 'pull_request'}} +# name: Create API preview on Bump.sh +# strategy: +# matrix: +# spec-mapping: ${{ fromJSON(needs.create-matrix.outputs.matrix) }} +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v4 +# - name: Create API preview +# uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c +# with: +# doc: ${{matrix.spec-mapping.doc}} +# token: ${{secrets.bump_token}} +# file: ${{matrix.spec-mapping.file}} +# branch: ${{matrix.spec-mapping.branch}} +# command: preview diff --git a/.github/workflows/release-spec-runner.yml b/.github/workflows/release-spec-runner.yml index 7aef7ad69d..6e9a0e5de1 100644 --- a/.github/workflows/release-spec-runner.yml +++ b/.github/workflows/release-spec-runner.yml @@ -52,6 +52,7 @@ jobs: secrets: api_bot_pat: ${{ secrets.API_BOT_PAT }} jira_api_token: ${{ secrets.JIRA_API_TOKEN }} + bump_token: ${{secrets.BUMP_TOKEN}} with: aws_default_region: ${{ vars.AWS_DEFAULT_REGION}} aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}} @@ -60,6 +61,8 @@ jobs: branch: dev spectral_version: ${{ vars.SPECTRAL_VERSION }} foascli_version: ${{ vars.FOASCLI_VERSION }} + atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID_DEV }} + atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID_DEV }} release-spec-qa: name: Release OpenAPI Spec for QA needs: release-preparation @@ -69,6 +72,7 @@ jobs: secrets: api_bot_pat: ${{ secrets.API_BOT_PAT }} jira_api_token: ${{ secrets.JIRA_API_TOKEN }} + bump_token: ${{secrets.BUMP_TOKEN}} with: aws_default_region: ${{ vars.AWS_DEFAULT_REGION}} aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }} @@ -77,6 +81,8 @@ jobs: branch: qa spectral_version: ${{ vars.SPECTRAL_VERSION }} foascli_version: ${{ vars.FOASCLI_VERSION }} + atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID_QA }} + atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID_QA }} release-spec-staging: name: Release OpenAPI Spec for STAGING needs: release-preparation @@ -86,6 +92,7 @@ jobs: secrets: api_bot_pat: ${{ secrets.API_BOT_PAT }} jira_api_token: ${{ secrets.JIRA_API_TOKEN }} + bump_token: ${{secrets.BUMP_TOKEN}} with: aws_default_region: ${{ vars.AWS_DEFAULT_REGION}} aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }} @@ -94,6 +101,8 @@ jobs: branch: staging spectral_version: ${{ vars.SPECTRAL_VERSION }} foascli_version: ${{ vars.FOASCLI_VERSION }} + atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID_STAGING }} + atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID_STAGING }} release-spec-prod: name: Release OpenAPI Spec for PROD needs: release-preparation @@ -105,6 +114,7 @@ jobs: postman_api_key: ${{ secrets.POSTMAN_API_KEY }} workspace_id: ${{ secrets.WORKSPACE_ID }} jira_api_token: ${{ secrets.JIRA_API_TOKEN }} + bump_token: ${{secrets.BUMP_TOKEN}} with: aws_default_region: ${{ vars.AWS_DEFAULT_REGION}} aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }} @@ -114,6 +124,8 @@ jobs: spectral_version: ${{ vars.SPECTRAL_VERSION }} foascli_version: ${{ vars.FOASCLI_VERSION }} atlas_prod_base_url: ${{ vars.ATLAS_PROD_BASE_URL }} + atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID }} + atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID }} release-spec-v1-prod: name: Release OpenAPI Spec V1 (Deprecated) for PROD diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index 6c12962127..aa5c562d38 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -34,6 +34,14 @@ on: description: 'AWS S3 Role to Assume.' required: true type: string + atlas_admin_v1_doc_id: + description: 'Bump Doc ID for the v1 spec' + required: true + type: string + atlas_admin_v2_doc_id: + description: 'Bump Doc ID for the v2 specs' + required: true + type: string secrets: # all secrets are passed explicitly in this workflow api_bot_pat: required: true @@ -49,6 +57,8 @@ on: required: false ipa_aws_s3_bucket_prefix: required: false + bump_token: + required: true permissions: contents: write @@ -184,6 +194,20 @@ jobs: branch: ${{ inputs.branch }} foascli_version: ${{ inputs.foascli_version }} + release-bump-sh: + name: Release API Specification to Bump.sh for ${{ inputs.branch }} + needs: release + if: ${{needs.release.outputs.changes_detected == 'true'}} + uses: ./.github/workflows/generate-bump-pages.yml + secrets: + api_bot_pat: ${{ secrets.api_bot_pat }} + bump_token: ${{ secrets.bump_token }} + with: + env: ${{ inputs.env }} + branch: ${{ inputs.branch }} + atlas_admin_v1_doc_id: ${{ inputs.atlas_admin_v1_doc_id }} + atlas_admin_v2_doc_id: ${{ inputs.atlas_admin_v2_doc_id }} + release-cleanup: needs: [ release, release-changelog] uses: ./.github/workflows/release-cleanup.yml From ad18aa54f15e110a6ef7d68c48c1eebcf14d186b Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Tue, 10 Jun 2025 14:48:30 +0200 Subject: [PATCH 02/10] Update generate-bump-pages.yml --- .github/workflows/generate-bump-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index 7448afc05c..21e2b13565 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -63,7 +63,7 @@ jobs: with: ref: ${{ inputs.branch }} token: ${{secrets.api_bot_pat}} - - name: Deploy API documentation - PROD + - name: Deploy API documentation - ${{inputs.branch}} uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c with: doc: ${{matrix.spec-mapping.doc}} From 4642246ce5f82292af2189ed8d0f74dda5760178 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Tue, 10 Jun 2025 15:18:05 +0200 Subject: [PATCH 03/10] Update generate-bump-pages.yml --- .github/workflows/generate-bump-pages.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index 21e2b13565..8fd64f5446 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -2,10 +2,6 @@ name: Release the OpenAPI spec to Bump.sh on: workflow_call: inputs: - env: - description: 'Environment to release the OpenAPI Spec to.' - required: true - type: string atlas_admin_v1_doc_id: description: 'Bump Doc ID for the v1 spec' required: true From 6223c3903c461546a4f5f5e9649dfc50a370c6b3 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Tue, 10 Jun 2025 15:18:26 +0200 Subject: [PATCH 04/10] Update release-spec.yml --- .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 aa5c562d38..17e778fa46 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -203,7 +203,6 @@ jobs: api_bot_pat: ${{ secrets.api_bot_pat }} bump_token: ${{ secrets.bump_token }} with: - env: ${{ inputs.env }} branch: ${{ inputs.branch }} atlas_admin_v1_doc_id: ${{ inputs.atlas_admin_v1_doc_id }} atlas_admin_v2_doc_id: ${{ inputs.atlas_admin_v2_doc_id }} From ca5a020b74859f320608e95c3105482e2510bf53 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Tue, 10 Jun 2025 21:25:17 +0200 Subject: [PATCH 05/10] Update generate-bump-pages.yml --- .github/workflows/generate-bump-pages.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index 8fd64f5446..38074e02f3 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -36,6 +36,15 @@ jobs: token: ${{secrets.api_bot_pat}} - name: Setup Node uses: actions/setup-node@v4 + - name: Download release scripts + uses: actions/download-artifact@v4 + with: + name: release-scripts + github-token: ${{ secrets.api_bot_pat }} + run-id: ${{ github.run_id }} + path: release-scripts + - name: Add permissions to execute scripts + run: chmod +x release-scripts/*.js - name: Generate matrix id: set-matrix env: @@ -43,7 +52,7 @@ jobs: ATLAS_ADMIN_V2_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} BRANCH_NAME: ${{ inputs.branch }} run: | - spec_mapping=$(node .github/scripts/generateSpecMapping.js) + spec_mapping=$(node release-scripts/generateSpecMapping.js) echo "matrix=$spec_mapping" >> "$GITHUB_OUTPUT" deploy-doc: From a62962692611ea48e5f0fa4cc301ef5b6e3f8e5f Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Wed, 11 Jun 2025 16:24:06 +0200 Subject: [PATCH 06/10] Addressed Raymund's comment --- .github/scripts/generateSpecMapping.js | 2 +- .github/workflows/generate-bump-pages.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/generateSpecMapping.js b/.github/scripts/generateSpecMapping.js index a136906ada..4361e1f931 100644 --- a/.github/scripts/generateSpecMapping.js +++ b/.github/scripts/generateSpecMapping.js @@ -12,7 +12,7 @@ const SPEC_MAPPING = [ { doc: process.env.ATLAS_ADMIN_V1_DOC_ID, file: 'openapi/v1-deprecated/v1.json', - branch: process.env.BRANCH_NAME + branch: 'main' }, ]; diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index 38074e02f3..4aac3a989b 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -50,7 +50,6 @@ jobs: env: ATLAS_ADMIN_V1_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} ATLAS_ADMIN_V2_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} - BRANCH_NAME: ${{ inputs.branch }} run: | spec_mapping=$(node release-scripts/generateSpecMapping.js) echo "matrix=$spec_mapping" >> "$GITHUB_OUTPUT" From c748aace20f0285c1a3bfd3bda85e5fdf0eea1e6 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Wed, 11 Jun 2025 16:24:23 +0200 Subject: [PATCH 07/10] Update generateSpecMapping.js --- .github/scripts/generateSpecMapping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/generateSpecMapping.js b/.github/scripts/generateSpecMapping.js index 4361e1f931..8c888623a7 100644 --- a/.github/scripts/generateSpecMapping.js +++ b/.github/scripts/generateSpecMapping.js @@ -12,7 +12,7 @@ const SPEC_MAPPING = [ { doc: process.env.ATLAS_ADMIN_V1_DOC_ID, file: 'openapi/v1-deprecated/v1.json', - branch: 'main' + branch: 'main', }, ]; From 5f6be7d9f078399d7b1dc6e1051c9c12ca92de4c Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Wed, 11 Jun 2025 19:05:42 +0200 Subject: [PATCH 08/10] fix release --- .github/scripts/generateSpecMapping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/generateSpecMapping.js b/.github/scripts/generateSpecMapping.js index 8c888623a7..560eff079a 100644 --- a/.github/scripts/generateSpecMapping.js +++ b/.github/scripts/generateSpecMapping.js @@ -19,7 +19,7 @@ const SPEC_MAPPING = [ function handleAdminAPIv2() { const docId = process.env.ATLAS_ADMIN_V2_DOC_ID; const directory = 'openapi/v2'; - const filePath = path.join(__dirname, `../../${directory}/versions.json`); + const filePath = path.join(__dirname, `../${directory}/versions.json`); const versions = JSON.parse(fs.readFileSync(filePath, 'utf8')); if (!versions || !Array.isArray(versions)) { From 54d0684153a0aca68c6223535cef4afb2b2d3bf3 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Wed, 11 Jun 2025 19:21:10 +0200 Subject: [PATCH 09/10] Update generateSpecMapping.js --- .github/scripts/generateSpecMapping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/generateSpecMapping.js b/.github/scripts/generateSpecMapping.js index 560eff079a..1d55247254 100644 --- a/.github/scripts/generateSpecMapping.js +++ b/.github/scripts/generateSpecMapping.js @@ -11,7 +11,7 @@ const __dirname = path.dirname(__filename); const SPEC_MAPPING = [ { doc: process.env.ATLAS_ADMIN_V1_DOC_ID, - file: 'openapi/v1-deprecated/v1.json', + file: 'v1-deprecated/v1.json', branch: 'main', }, ]; From 30e2a1b7a11ab59ab96ec3276acddc29589108b3 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Wed, 11 Jun 2025 19:29:31 +0200 Subject: [PATCH 10/10] fix release --- .github/workflows/generate-bump-pages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index 4aac3a989b..db221e00a1 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -49,10 +49,10 @@ jobs: id: set-matrix env: ATLAS_ADMIN_V1_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} - ATLAS_ADMIN_V2_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }} + ATLAS_ADMIN_V2_DOC_ID: ${{ inputs.atlas_admin_v2_doc_id }} run: | spec_mapping=$(node release-scripts/generateSpecMapping.js) - echo "matrix=$spec_mapping" >> "$GITHUB_OUTPUT" + echo "matrix=${spec_mapping}" >> "${GITHUB_OUTPUT}" deploy-doc: needs: create-matrix