diff --git a/.github/workflows/generate-bump-pages.yml b/.github/workflows/generate-bump-pages.yml index db920ca28e..4aac3a989b 100644 --- a/.github/workflows/generate-bump-pages.yml +++ b/.github/workflows/generate-bump-pages.yml @@ -1,20 +1,24 @@ -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: + 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 +31,68 @@ 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: 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: - 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 }} run: | - spec_mapping=$(node .github/scripts/generateSpecMapping.js) + spec_mapping=$(node release-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 - ${{inputs.branch}} 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 6cd4da6f49..d327e83fe2 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,19 @@ 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: + 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