-
Notifications
You must be signed in to change notification settings - Fork 2
262 lines (236 loc) · 9.15 KB
/
bump.yml
File metadata and controls
262 lines (236 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Check and deploy API documentation
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
pull-requests: write
id-token: write
jobs:
determine-doc-ids:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set matrix
id: set-matrix
run: |
DOCS=()
for d in */ ; do
# Exclude shared and .github or any other non-doc folders
if [[ "$d" == "shared/" || "$d" == ".github/" ]]; then
continue
fi
base="${d%/}"
if [[ -f "${base}/${base}.yaml" || -f "${base}/${base}.yml" || -f "${base}/${base}.json" ]]; then
DOCS+=("${base}")
fi
done
if [ ${#DOCS[@]} -eq 0 ]; then
echo "No doc folders found. Exiting workflow."
echo "matrix={\"doc_id\":[]}" >> "$GITHUB_OUTPUT"
exit 0
fi
JSON_ARRAY=$(printf '"%s",' "${DOCS[@]}" | sed 's/,$//')
JSON_MATRIX="{\"doc_id\":[${JSON_ARRAY}]}"
echo "matrix=$JSON_MATRIX" >> "$GITHUB_OUTPUT"
echo "Created matrix: $JSON_MATRIX"
deploy-doc:
if: ${{ github.event_name == 'push' && fromJson(needs.determine-doc-ids.outputs.matrix).doc_id[0] != null }}
needs: determine-doc-ids
name: Deploy API documentation on Bump.sh
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.determine-doc-ids.outputs.matrix) }}
fail-fast: false
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.RP_AWS_CRED_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }}
- uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
,sdlc/prod/github/bump_api_key
parse-json-secrets: true
- name: Checkout
uses: actions/checkout@v4
# Figure out the file path for non-admin docs
- name: Determine file format (non-admin)
id: format
if: ${{ matrix.doc_id != 'admin' }}
run: |
base="${{ matrix.doc_id }}"
if [ -f "${base}/${base}.yaml" ]; then
echo "file_path=${base}/${base}.yaml" >> "$GITHUB_OUTPUT"
elif [ -f "${base}/${base}.yml" ]; then
echo "file_path=${base}/${base}.yml" >> "$GITHUB_OUTPUT"
elif [ -f "${base}/${base}.json" ]; then
echo "file_path=${base}/${base}.json" >> "$GITHUB_OUTPUT"
else
echo "No API definition file found for ${base}"
exit 1
fi
- name: Determine overlays (non-admin)
id: overlays
if: ${{ matrix.doc_id != 'admin' }}
run: |
OVERLAYS=$(.github/scripts/determine-overlays.sh "${{ matrix.doc_id }}")
echo "overlay_paths=$OVERLAYS" >> "$GITHUB_OUTPUT"
echo "Using overlays: $OVERLAYS"
- name: Determine admin v1 overlays
id: admin-v1-overlays
if: ${{ matrix.doc_id == 'admin' }}
run: |
OVERLAYS=$(.github/scripts/determine-overlays.sh admin v1)
echo "overlay_paths=$OVERLAYS" >> "$GITHUB_OUTPUT"
echo "Using v1 overlays: $OVERLAYS"
- name: Determine admin v2 overlays
id: admin-v2-overlays
if: ${{ matrix.doc_id == 'admin' }}
run: |
OVERLAYS=$(.github/scripts/determine-overlays.sh admin v2)
echo "overlay_paths=$OVERLAYS" >> "$GITHUB_OUTPUT"
echo "Using v2 overlays: $OVERLAYS"
# ---- Admin v1 explicit deploy (only when matrix.doc_id == admin) ----
- name: Deploy API documentation (admin v1)
if: ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin.yaml') != '' }}
uses: bump-sh/github-action@v1
with:
hub: redpanda
doc: admin
token: ${{ env.BUMP_API_KEY }}
file: admin/admin.yaml
overlay: ${{ steps.admin-v1-overlays.outputs.overlay_paths }}
branch: v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---- Admin v2 explicit deploy (only when matrix.doc_id == admin) ----
- name: Deploy API documentation (admin v2)
if: ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin-v2.yaml') != '' }}
uses: bump-sh/github-action@v1
with:
hub: redpanda
doc: admin
token: ${{ env.BUMP_API_KEY }}
file: admin/admin-v2.yaml
overlay: ${{ steps.admin-v2-overlays.outputs.overlay_paths }}
branch: v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---- Other docs (non-admin) ----
- name: Deploy API documentation (other files)
if: ${{ matrix.doc_id != 'admin' }}
uses: bump-sh/github-action@v1
with:
hub: redpanda
doc: ${{ matrix.doc_id }}
token: ${{ env.BUMP_API_KEY }}
file: ${{ steps.format.outputs.file_path }}
overlay: ${{ steps.overlays.outputs.overlay_paths }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
api-diff:
if: ${{ github.event_name == 'pull_request' && fromJson(needs.determine-doc-ids.outputs.matrix).doc_id[0] != null }}
needs: determine-doc-ids
name: Check diff
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.determine-doc-ids.outputs.matrix) }}
fail-fast: false
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.RP_AWS_CRED_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }}
- uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
,sdlc/prod/github/bump_api_key
parse-json-secrets: true
- name: Checkout
uses: actions/checkout@v4
# For non-admin docs, resolve file path
- name: Determine file format (non-admin)
id: format
if: ${{ matrix.doc_id != 'admin' }}
run: |
base="${{ matrix.doc_id }}"
if [ -f "${base}/${base}.yaml" ]; then
echo "file_path=${base}/${base}.yaml" >> "$GITHUB_OUTPUT"
elif [ -f "${base}/${base}.yml" ]; then
echo "file_path=${base}/${base}.yml" >> "$GITHUB_OUTPUT"
elif [ -f "${base}/${base}.json" ]; then
echo "file_path=${base}/${base}.json" >> "$GITHUB_OUTPUT"
else
echo "No API definition file found for ${base}"
exit 1
fi
- name: Determine overlays (non-admin)
id: overlays
if: ${{ matrix.doc_id != 'admin' }}
run: |
OVERLAYS=$(.github/scripts/determine-overlays.sh "${{ matrix.doc_id }}")
echo "overlay_paths=$OVERLAYS" >> "$GITHUB_OUTPUT"
echo "Using overlays: $OVERLAYS"
- name: Determine admin v1 overlays
id: admin-v1-overlays
if: ${{ matrix.doc_id == 'admin' }}
run: |
OVERLAYS=$(.github/scripts/determine-overlays.sh admin v1)
echo "overlay_paths=$OVERLAYS" >> "$GITHUB_OUTPUT"
echo "Using v1 overlays: $OVERLAYS"
- name: Determine admin v2 overlays
id: admin-v2-overlays
if: ${{ matrix.doc_id == 'admin' }}
run: |
OVERLAYS=$(.github/scripts/determine-overlays.sh admin v2)
echo "overlay_paths=$OVERLAYS" >> "$GITHUB_OUTPUT"
echo "Using v2 overlays: $OVERLAYS"
# ---- Admin v1 explicit diff ----
- name: Comment PR with API diff (admin v1)
if: ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin.yaml') != '' }}
uses: bump-sh/github-action@v1
with:
hub: redpanda
doc: admin
token: ${{ env.BUMP_API_KEY }}
file: admin/admin.yaml
overlay: ${{ steps.admin-v1-overlays.outputs.overlay_paths }}
command: diff
branch: v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---- Admin v2 explicit diff ----
- name: Comment PR with API diff (admin v2)
if: ${{ matrix.doc_id == 'admin' && hashFiles('admin/admin-v2.yaml') != '' }}
uses: bump-sh/github-action@v1
with:
hub: redpanda
doc: admin
token: ${{ env.BUMP_API_KEY }}
file: admin/admin-v2.yaml
overlay: ${{ steps.admin-v2-overlays.outputs.overlay_paths }}
command: diff
branch: v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---- Other docs (non-admin) ----
- name: Comment PR with API diff (other files)
if: ${{ matrix.doc_id != 'admin' }}
uses: bump-sh/github-action@v1
with:
hub: redpanda
doc: ${{ matrix.doc_id }}
token: ${{ env.BUMP_API_KEY }}
file: ${{ steps.format.outputs.file_path }}
overlay: ${{ steps.overlays.outputs.overlay_paths }}
command: diff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}