Skip to content

Commit 71e56d3

Browse files
CLOUDP-323790: Update foas release process to support bump.sh deployment for all the envs (#752)
1 parent cbe3c2e commit 71e56d3

File tree

3 files changed

+97
-42
lines changed

3 files changed

+97
-42
lines changed
Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
name: Check & deploy API documentation
2-
1+
name: Release the OpenAPI spec to Bump.sh
32
on:
4-
# For deployments
5-
workflow_dispatch: # Allow manual trigger in case of quick fix
6-
push:
7-
branches:
8-
- main
9-
paths:
10-
- 'openapi/**.json'
11-
12-
# For previews
13-
pull_request:
14-
branches:
15-
- main
16-
paths:
17-
- 'openapi/**.json'
3+
workflow_call:
4+
inputs:
5+
atlas_admin_v1_doc_id:
6+
description: 'Bump Doc ID for the v1 spec'
7+
required: true
8+
type: string
9+
atlas_admin_v2_doc_id:
10+
description: 'Bump Doc ID for the v2 specs'
11+
required: true
12+
type: string
13+
branch:
14+
description: 'Branch to release the OpenAPI Spec to.'
15+
required: true
16+
type: string
17+
secrets:
18+
api_bot_pat:
19+
required: true
20+
bump_token:
21+
required: true
1822

1923
permissions:
2024
contents: read
@@ -27,52 +31,68 @@ jobs:
2731
steps:
2832
- name: Checkout repository
2933
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ inputs.branch }}
36+
token: ${{secrets.api_bot_pat}}
3037
- name: Setup Node
3138
uses: actions/setup-node@v4
39+
- name: Download release scripts
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: release-scripts
43+
github-token: ${{ secrets.api_bot_pat }}
44+
run-id: ${{ github.run_id }}
45+
path: release-scripts
46+
- name: Add permissions to execute scripts
47+
run: chmod +x release-scripts/*.js
3248
- name: Generate matrix
3349
id: set-matrix
3450
env:
35-
ATLAS_ADMIN_V1_DOC_ID: ${{ vars.ATLAS_ADMIN_V1_DOC_ID }}
36-
ATLAS_ADMIN_V2_DOC_ID: ${{ vars.ATLAS_ADMIN_V2_DOC_ID }}
51+
ATLAS_ADMIN_V1_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }}
52+
ATLAS_ADMIN_V2_DOC_ID: ${{ inputs.atlas_admin_v1_doc_id }}
3753
run: |
38-
spec_mapping=$(node .github/scripts/generateSpecMapping.js)
54+
spec_mapping=$(node release-scripts/generateSpecMapping.js)
3955
echo "matrix=$spec_mapping" >> "$GITHUB_OUTPUT"
4056
4157
deploy-doc:
4258
needs: create-matrix
43-
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
4459
name: Deploy API documentation on Bump.sh
4560
strategy:
4661
matrix:
4762
spec-mapping: ${{ fromJson(needs.create-matrix.outputs.matrix) }}
4863
runs-on: ubuntu-latest
4964
steps:
50-
- name: Checkout
65+
- name: Checkout repository
5166
uses: actions/checkout@v4
52-
- name: Deploy API documentation
53-
uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c
5467
with:
55-
doc: ${{matrix.spec-mapping.doc}}
56-
token: ${{secrets.BUMP_TOKEN}}
57-
file: ${{matrix.spec-mapping.file}}
58-
branch: ${{matrix.spec-mapping.branch}}
59-
60-
api-preview:
61-
needs: create-matrix
62-
if: ${{ github.event_name == 'pull_request' }}
63-
name: Create API preview on Bump.sh
64-
strategy:
65-
matrix:
66-
spec-mapping: ${{ fromJSON(needs.create-matrix.outputs.matrix) }}
67-
runs-on: ubuntu-latest
68-
steps:
69-
- name: Checkout
70-
uses: actions/checkout@v4
71-
- name: Create API preview
68+
ref: ${{ inputs.branch }}
69+
token: ${{secrets.api_bot_pat}}
70+
- name: Deploy API documentation - ${{inputs.branch}}
7271
uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c
7372
with:
7473
doc: ${{matrix.spec-mapping.doc}}
75-
token: ${{secrets.BUMP_TOKEN}}
74+
token: ${{secrets.bump_token}}
7675
file: ${{matrix.spec-mapping.file}}
7776
branch: ${{matrix.spec-mapping.branch}}
78-
command: preview
77+
78+
# We don't need to preview the API since the PR is autogenerated and always merge into master
79+
# we will migrate this logic to another workflow that can be trigger ondemand by adding a label to a PR.
80+
# api-preview:
81+
# needs: create-matrix
82+
# if: ${{ github.event_name == 'pull_request'}}
83+
# name: Create API preview on Bump.sh
84+
# strategy:
85+
# matrix:
86+
# spec-mapping: ${{ fromJSON(needs.create-matrix.outputs.matrix) }}
87+
# runs-on: ubuntu-latest
88+
# steps:
89+
# - name: Checkout
90+
# uses: actions/checkout@v4
91+
# - name: Create API preview
92+
# uses: bump-sh/github-action@59eaae922e81ac8d127bd2b2ac6dc4804bda8a4c
93+
# with:
94+
# doc: ${{matrix.spec-mapping.doc}}
95+
# token: ${{secrets.bump_token}}
96+
# file: ${{matrix.spec-mapping.file}}
97+
# branch: ${{matrix.spec-mapping.branch}}
98+
# command: preview

.github/workflows/release-spec-runner.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
secrets:
5353
api_bot_pat: ${{ secrets.API_BOT_PAT }}
5454
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
55+
bump_token: ${{secrets.BUMP_TOKEN}}
5556
with:
5657
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
5758
aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}}
@@ -60,6 +61,8 @@ jobs:
6061
branch: dev
6162
spectral_version: ${{ vars.SPECTRAL_VERSION }}
6263
foascli_version: ${{ vars.FOASCLI_VERSION }}
64+
atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID_DEV }}
65+
atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID_DEV }}
6366
release-spec-qa:
6467
name: Release OpenAPI Spec for QA
6568
needs: release-preparation
@@ -69,6 +72,7 @@ jobs:
6972
secrets:
7073
api_bot_pat: ${{ secrets.API_BOT_PAT }}
7174
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
75+
bump_token: ${{secrets.BUMP_TOKEN}}
7276
with:
7377
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
7478
aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }}
@@ -77,6 +81,8 @@ jobs:
7781
branch: qa
7882
spectral_version: ${{ vars.SPECTRAL_VERSION }}
7983
foascli_version: ${{ vars.FOASCLI_VERSION }}
84+
atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID_QA }}
85+
atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID_QA }}
8086
release-spec-staging:
8187
name: Release OpenAPI Spec for STAGING
8288
needs: release-preparation
@@ -86,6 +92,7 @@ jobs:
8692
secrets:
8793
api_bot_pat: ${{ secrets.API_BOT_PAT }}
8894
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
95+
bump_token: ${{secrets.BUMP_TOKEN}}
8996
with:
9097
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
9198
aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }}
@@ -94,6 +101,8 @@ jobs:
94101
branch: staging
95102
spectral_version: ${{ vars.SPECTRAL_VERSION }}
96103
foascli_version: ${{ vars.FOASCLI_VERSION }}
104+
atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID_STAGING }}
105+
atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID_STAGING }}
97106
release-spec-prod:
98107
name: Release OpenAPI Spec for PROD
99108
needs: release-preparation
@@ -105,6 +114,7 @@ jobs:
105114
postman_api_key: ${{ secrets.POSTMAN_API_KEY }}
106115
workspace_id: ${{ secrets.WORKSPACE_ID }}
107116
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
117+
bump_token: ${{secrets.BUMP_TOKEN}}
108118
with:
109119
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
110120
aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }}
@@ -114,6 +124,8 @@ jobs:
114124
spectral_version: ${{ vars.SPECTRAL_VERSION }}
115125
foascli_version: ${{ vars.FOASCLI_VERSION }}
116126
atlas_prod_base_url: ${{ vars.ATLAS_PROD_BASE_URL }}
127+
atlas_admin_v2_doc_id: ${{vars.ATLAS_ADMIN_V2_DOC_ID }}
128+
atlas_admin_v1_doc_id: ${{vars.ATLAS_ADMIN_V1_DOC_ID }}
117129

118130
release-spec-v1-prod:
119131
name: Release OpenAPI Spec V1 (Deprecated) for PROD

.github/workflows/release-spec.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ on:
3434
description: 'AWS S3 Role to Assume.'
3535
required: true
3636
type: string
37+
atlas_admin_v1_doc_id:
38+
description: 'Bump Doc ID for the v1 spec'
39+
required: true
40+
type: string
41+
atlas_admin_v2_doc_id:
42+
description: 'Bump Doc ID for the v2 specs'
43+
required: true
44+
type: string
3745
secrets: # all secrets are passed explicitly in this workflow
3846
api_bot_pat:
3947
required: true
@@ -49,6 +57,8 @@ on:
4957
required: false
5058
ipa_aws_s3_bucket_prefix:
5159
required: false
60+
bump_token:
61+
required: true
5262

5363
permissions:
5464
contents: write
@@ -184,6 +194,19 @@ jobs:
184194
branch: ${{ inputs.branch }}
185195
foascli_version: ${{ inputs.foascli_version }}
186196

197+
release-bump-sh:
198+
name: Release API Specification to Bump.sh for ${{ inputs.branch }}
199+
needs: release
200+
if: ${{needs.release.outputs.changes_detected == 'true'}}
201+
uses: ./.github/workflows/generate-bump-pages.yml
202+
secrets:
203+
api_bot_pat: ${{ secrets.api_bot_pat }}
204+
bump_token: ${{ secrets.bump_token }}
205+
with:
206+
branch: ${{ inputs.branch }}
207+
atlas_admin_v1_doc_id: ${{ inputs.atlas_admin_v1_doc_id }}
208+
atlas_admin_v2_doc_id: ${{ inputs.atlas_admin_v2_doc_id }}
209+
187210
release-cleanup:
188211
needs: [ release, release-changelog]
189212
uses: ./.github/workflows/release-cleanup.yml

0 commit comments

Comments
 (0)