1- name : Check & deploy API documentation
2-
1+ name : Release the OpenAPI spec to Bump.sh
32on :
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
1923permissions :
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
0 commit comments