@@ -2,23 +2,33 @@ name: Check and deploy API documentation
22
33on :
44 push :
5- branches :
6- - main
7-
5+ branches : [ main ]
86 pull_request :
9- branches :
10- - main
7+ branches : [ main ]
118
129permissions :
1310 contents : read
1411 pull-requests : write
12+ id-token : write
1513
1614jobs :
1715 determine-doc-ids :
1816 runs-on : ubuntu-latest
1917 outputs :
2018 matrix : ${{ steps.set-matrix.outputs.matrix }}
2119 steps :
20+
21+ - uses : aws-actions/configure-aws-credentials@v4
22+ with :
23+ aws-region : ${{ vars.RP_AWS_CRED_REGION }}
24+ role-to-assume : arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }}
25+
26+ - uses : aws-actions/aws-secretsmanager-get-secrets@v2
27+ with :
28+ secret-ids : |
29+ ,sdlc/prod/github/bump_api_key
30+ parse-json-secrets : true
31+
2232 - name : Checkout
2333 uses : actions/checkout@v4
2434 with :
@@ -30,12 +40,15 @@ jobs:
3040 DOCS=()
3141 for d in */ ; do
3242 # Exclude shared and .github or any other non-doc folders
33- if [[ "$d" != "shared/" && "$d" != ".github/" && ( -f "${d%/}/${d%/}.yaml" || -f "${d%/}/${d%/}.json" ) ]]; then
34- DOCS+=("${d%/}")
43+ if [[ "$d" == "shared/" || "$d" == ".github/" ]]; then
44+ continue
45+ fi
46+ base="${d%/}"
47+ if [[ -f "${base}/${base}.yaml" || -f "${base}/${base}.yml" || -f "${base}/${base}.json" ]]; then
48+ DOCS+=("${base}")
3549 fi
3650 done
3751
38- # If no doc folders found, abort the workflow
3952 if [ ${#DOCS[@]} -eq 0 ]; then
4053 echo "No doc folders found. Exiting workflow."
4154 echo "matrix={\"doc_id\":[]}" >> $GITHUB_OUTPUT
@@ -53,68 +66,173 @@ jobs:
5366 name : Deploy API documentation on Bump.sh
5467 runs-on : ubuntu-latest
5568 strategy :
56- matrix : ${{fromJson(needs.determine-doc-ids.outputs.matrix)}}
69+ matrix : ${{ fromJson(needs.determine-doc-ids.outputs.matrix) }}
5770 fail-fast : false
5871 steps :
5972 - name : Checkout
6073 uses : actions/checkout@v4
6174
62- - name : Determine file format
75+ # Figure out the file path for non-admin docs
76+ - name : Determine file format (non-admin)
6377 id : format
6478 run : |
65- if [ -f "${{ matrix.doc_id }}/${{ matrix.doc_id }}.yaml" ]; then
66- echo "file_path=${{ matrix.doc_id }}/${{ matrix.doc_id }}.yaml" >> $GITHUB_OUTPUT
67- elif [ -f "${{ matrix.doc_id }}/${{ matrix.doc_id }}.json" ]; then
68- echo "file_path=${{ matrix.doc_id }}/${{ matrix.doc_id }}.json" >> $GITHUB_OUTPUT
79+ base="${{ matrix.doc_id }}"
80+ if [ "$base" = "admin" ]; then
81+ # Not used for admin; we deploy v1/v2 explicitly below
82+ echo "file_path=" >> $GITHUB_OUTPUT
83+ exit 0
84+ fi
85+ if [ -f "${base}/${base}.yaml" ]; then
86+ echo "file_path=${base}/${base}.yaml" >> $GITHUB_OUTPUT
87+ elif [ -f "${base}/${base}.yml" ]; then
88+ echo "file_path=${base}/${base}.yml" >> $GITHUB_OUTPUT
89+ elif [ -f "${base}/${base}.json" ]; then
90+ echo "file_path=${base}/${base}.json" >> $GITHUB_OUTPUT
6991 else
70- echo "No API definition file found for ${{ matrix.doc_id } }"
92+ echo "No API definition file found for ${base }"
7193 exit 1
7294 fi
7395
74- - name : Determine overlays
96+ - name : Determine overlays (non-admin)
7597 id : overlays
7698 run : |
7799 OVERLAYS=""
100+ DOC_ID="${{ matrix.doc_id }}"
101+
102+ # Skip overlay determination for admin - handled separately
103+ if [ "$DOC_ID" = "admin" ]; then
104+ echo "overlay_paths=" >> $GITHUB_OUTPUT
105+ exit 0
106+ fi
78107
79- # Add doc -specific overlays (if any)
80- if [ -d "${{ matrix.doc_id } }/overlays" ]; then
108+ # Doc -specific overlays
109+ if [ -d "${DOC_ID }/overlays" ]; then
81110 shopt -s nullglob
82- for overlay_file in "${{ matrix.doc_id }}/overlays"/*.yaml; do
83- if [ -f "$overlay_file" ]; then
84- OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
85- fi
111+ for overlay_file in "${DOC_ID}/overlays"/*.yaml; do
112+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
86113 done
87114 shopt -u nullglob
88115 fi
89116
90- # Determine shared overlay prefix
91- if [[ "${{ matrix.doc_id }} " == " cloud-" * ]]; then
92- OVERLAY_PREFIX ="cloud-"
117+ # Shared overlays
118+ if [[ "$DOC_ID " == cloud-* ]]; then
119+ PREFIX ="cloud-"
93120 else
94- OVERLAY_PREFIX ="sm-"
121+ PREFIX ="sm-"
95122 fi
96-
97- # Add matching shared overlays
98123 if [ -d "shared/overlays" ]; then
99124 shopt -s nullglob
100- for overlay_file in shared/overlays/${OVERLAY_PREFIX}*.yaml; do
101- if [ -f "$overlay_file" ]; then
102- OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
103- fi
125+ for overlay_file in shared/overlays/${PREFIX}*.yaml; do
126+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
104127 done
105128 shopt -u nullglob
106129 fi
107130
108131 echo "overlay_paths=$OVERLAYS" >> $GITHUB_OUTPUT
109132 echo "Using overlays: $OVERLAYS"
110133
134+ - name : Determine admin v1 overlays
135+ id : admin-v1-overlays
136+ run : |
137+ OVERLAYS=""
138+ DOC_ID="${{ matrix.doc_id }}"
139+
140+ # Only run for admin
141+ if [ "$DOC_ID" != "admin" ]; then
142+ echo "overlay_paths=" >> $GITHUB_OUTPUT
143+ exit 0
144+ fi
145+
146+ # Admin v1-specific overlays
147+ if [ -d "admin/v1-overlays" ]; then
148+ shopt -s nullglob
149+ for overlay_file in admin/v1-overlays/*.yaml; do
150+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
151+ done
152+ shopt -u nullglob
153+ fi
154+
155+ # Shared overlays for self-managed (admin is sm)
156+ if [ -d "shared/overlays" ]; then
157+ shopt -s nullglob
158+ for overlay_file in shared/overlays/sm-*.yaml; do
159+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
160+ done
161+ shopt -u nullglob
162+ fi
163+
164+ echo "overlay_paths=$OVERLAYS" >> $GITHUB_OUTPUT
165+ echo "Using v1 overlays: $OVERLAYS"
166+
167+ - name : Determine admin v2 overlays
168+ id : admin-v2-overlays
169+ run : |
170+ OVERLAYS=""
171+ DOC_ID="${{ matrix.doc_id }}"
172+
173+ # Only run for admin
174+ if [ "$DOC_ID" != "admin" ]; then
175+ echo "overlay_paths=" >> $GITHUB_OUTPUT
176+ exit 0
177+ fi
178+
179+ # Admin v2-specific overlays
180+ if [ -d "admin/v2-overlays" ]; then
181+ shopt -s nullglob
182+ for overlay_file in admin/v2-overlays/*.yaml; do
183+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
184+ done
185+ shopt -u nullglob
186+ fi
187+
188+ # Shared overlays for self-managed (admin is sm)
189+ if [ -d "shared/overlays" ]; then
190+ shopt -s nullglob
191+ for overlay_file in shared/overlays/sm-*.yaml; do
192+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
193+ done
194+ shopt -u nullglob
195+ fi
196+
197+ echo "overlay_paths=$OVERLAYS" >> $GITHUB_OUTPUT
198+ echo "Using v2 overlays: $OVERLAYS"
199+
200+ # ---- Admin v1 explicit deploy (only when matrix.doc_id == admin) ----
201+ - name : Deploy API documentation (admin v1)
202+ if : ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin.yaml') != '' }}
203+ uses : bump-sh/github-action@v1
204+ with :
205+ hub : redpanda
206+ doc : admin
207+ token : ${{ env.BUMP_API_KEY }}
208+ file : admin/admin.yaml
209+ overlay : ${{ steps.admin-v1-overlays.outputs.overlay_paths }}
210+ branch : v1
211+ env :
212+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
213+
214+ # ---- Admin v2 explicit deploy (only when matrix.doc_id == admin) ----
215+ - name : Deploy API documentation (admin v2)
216+ if : ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin-v2.yaml') != '' }}
217+ uses : bump-sh/github-action@v1
218+ with :
219+ hub : redpanda
220+ doc : admin
221+ token : ${{ env.BUMP_API_KEY }}
222+ file : admin/admin-v2.yaml
223+ overlay : ${{ steps.admin-v2-overlays.outputs.overlay_paths }}
224+ branch : v2
225+ env :
226+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
111227
112- - name : Deploy API documentation
228+ # ---- Other docs (non-admin) ----
229+ - name : Deploy API documentation (other files)
230+ if : ${{ matrix.doc_id != 'admin' }}
113231 uses : bump-sh/github-action@v1
114232 with :
115233 hub : redpanda
116234 doc : ${{ matrix.doc_id }}
117- token : ${{secrets.BUMP_TOKEN }}
235+ token : ${{ env.BUMP_API_KEY }}
118236 file : ${{ steps.format.outputs.file_path }}
119237 overlay : ${{ steps.overlays.outputs.overlay_paths }}
120238 env :
@@ -126,70 +244,100 @@ jobs:
126244 name : Check diff
127245 runs-on : ubuntu-latest
128246 strategy :
129- matrix : ${{fromJson(needs.determine-doc-ids.outputs.matrix)}}
247+ matrix : ${{ fromJson(needs.determine-doc-ids.outputs.matrix) }}
130248 fail-fast : false
131249 steps :
132250 - name : Checkout
133251 uses : actions/checkout@v4
134252
135- - name : Determine file format
253+ # For non-admin docs, resolve file path
254+ - name : Determine file format (non-admin)
136255 id : format
137256 run : |
138- if [ -f "${{ matrix.doc_id }}/${{ matrix.doc_id }}.yaml" ]; then
139- echo "file_path=${{ matrix.doc_id }}/${{ matrix.doc_id }}.yaml" >> $GITHUB_OUTPUT
140- elif [ -f "${{ matrix.doc_id }}/${{ matrix.doc_id }}.json" ]; then
141- echo "file_path=${{ matrix.doc_id }}/${{ matrix.doc_id }}.json" >> $GITHUB_OUTPUT
142- elif [ -f "${{ matrix.doc_id }}/${{ matrix.doc_id }}-api.json" ]; then
143- echo "file_path=${{ matrix.doc_id }}/${{ matrix.doc_id }}-api.json" >> $GITHUB_OUTPUT
257+ base="${{ matrix.doc_id }}"
258+ if [ "$base" = "admin" ]; then
259+ echo "file_path=" >> $GITHUB_OUTPUT
260+ exit 0
261+ fi
262+ if [ -f "${base}/${base}.yaml" ]; then
263+ echo "file_path=${base}/${base}.yaml" >> $GITHUB_OUTPUT
264+ elif [ -f "${base}/${base}.yml" ]; then
265+ echo "file_path=${base}/${base}.yml" >> $GITHUB_OUTPUT
266+ elif [ -f "${base}/${base}.json" ]; then
267+ echo "file_path=${base}/${base}.json" >> $GITHUB_OUTPUT
144268 else
145- echo "No API definition file found for ${{ matrix.doc_id } }"
269+ echo "No API definition file found for ${base }"
146270 exit 1
147271 fi
148272
149273 - name : Determine overlays
150274 id : overlays
151275 run : |
152276 OVERLAYS=""
277+ DOC_ID="${{ matrix.doc_id }}"
153278
154- # Add doc-specific overlays (if any)
155- if [ -d "${{ matrix.doc_id }}/overlays" ]; then
279+ if [ -d "${DOC_ID}/overlays" ]; then
156280 shopt -s nullglob
157- for overlay_file in "${{ matrix.doc_id }}/overlays"/*.yaml; do
158- if [ -f "$overlay_file" ]; then
159- OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
160- fi
281+ for overlay_file in "${DOC_ID}/overlays"/*.yaml; do
282+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
161283 done
162284 shopt -u nullglob
163285 fi
164286
165- # Determine shared overlay prefix
166- if [[ "${{ matrix.doc_id }}" == "cloud-"* ]]; then
167- OVERLAY_PREFIX="cloud-"
287+ if [[ "$DOC_ID" == cloud-* ]]; then
288+ PREFIX="cloud-"
168289 else
169- OVERLAY_PREFIX ="sm-"
290+ PREFIX ="sm-"
170291 fi
171-
172- # Add matching shared overlays
173292 if [ -d "shared/overlays" ]; then
174293 shopt -s nullglob
175- for overlay_file in shared/overlays/${OVERLAY_PREFIX}*.yaml; do
176- if [ -f "$overlay_file" ]; then
177- OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
178- fi
294+ for overlay_file in shared/overlays/${PREFIX}*.yaml; do
295+ [ -f "$overlay_file" ] && OVERLAYS="${OVERLAYS:+$OVERLAYS,}$overlay_file"
179296 done
180297 shopt -u nullglob
181298 fi
182299
183300 echo "overlay_paths=$OVERLAYS" >> $GITHUB_OUTPUT
184301 echo "Using overlays: $OVERLAYS"
185302
303+ # ---- Admin v1 explicit diff ----
304+ - name : Comment PR with API diff (admin v1)
305+ if : ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin.yaml') != '' }}
306+ uses : bump-sh/github-action@v1
307+ with :
308+ hub : redpanda
309+ doc : admin
310+ token : ${{ env.BUMP_API_KEY }}
311+ file : admin/admin.yaml
312+ overlay : ${{ steps.overlays.outputs.overlay_paths }}
313+ command : diff
314+ branch : v1
315+ env :
316+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
317+
318+ # ---- Admin v2 explicit diff ----
319+ - name : Comment PR with API diff (admin v2)
320+ if : ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin-v2.yaml') != '' }}
321+ uses : bump-sh/github-action@v1
322+ with :
323+ hub : redpanda
324+ doc : admin
325+ token : ${{ env.BUMP_API_KEY }}
326+ file : admin/admin-v2.yaml
327+ overlay : ${{ steps.overlays.outputs.overlay_paths }}
328+ command : diff
329+ branch : v2
330+ env :
331+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
186332
187- - name : Comment pull request with API diff
333+ # ---- Other docs (non-admin) ----
334+ - name : Comment PR with API diff (other files)
335+ if : ${{ matrix.doc_id != 'admin' }}
188336 uses : bump-sh/github-action@v1
189337 with :
190338 hub : redpanda
191339 doc : ${{ matrix.doc_id }}
192- token : ${{secrets.BUMP_TOKEN }}
340+ token : ${{ env.BUMP_API_KEY }}
193341 file : ${{ steps.format.outputs.file_path }}
194342 overlay : ${{ steps.overlays.outputs.overlay_paths }}
195343 command : diff
0 commit comments