-
Notifications
You must be signed in to change notification settings - Fork 0
350 lines (304 loc) · 12.3 KB
/
tyk-docs.yml
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# yamllint disable rule:line-length
---
name: Tyk Docs sync
run-name: '[${{ inputs.jira }}] ${{ github.actor }} running tyk-docs sync'
# This workflow builds the documentation for a release.
# It uses the following external dependencies:
#
# Generator: tyk-config-info-generator
# Provides: tyk-docs/content/shared/gateway-config.md
# Source: https://github.com/TykTechnologies/tyk-config-info-generator
#
# Generator: schema-gen markdown
# Provides: tyk-docs/content/shared/x-tyk-gateway.md
# Source: https://github.com/TykTechnologies/exp/tree/main/cmd/schema-gen
#
# The schema-gen tool is provided using the tykio/ci-tools docker image.
# To rebuild that docker image if required, trigger an update via:
#
# https://github.com/TykTechnologies/tyk-github-actions/actions/workflows/ci-docker-tools.yml
#
# You can test the schema-gen docs generator in this repo: pkg/model/Taskfile.yml;
# Running the taskfile with `task` will generate gateway/README.md, among other files.
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
jira:
description: JIRA ID (MM-NNNN or permalink)
required: true
default: ''
sync-gateway:
description: Include Gateway
type: boolean
sync-dashboard:
description: Include Dashboard
type: boolean
sync-pump:
description: Include Pump
type: boolean
sync-mdcb:
description: Include MDCB
type: boolean
release:
description: 'Release version'
type: choice
options:
- 'master'
- '5.3'
- '5.2'
- '5.1'
- '5.0 LTS'
source:
description: 'Override source branch'
default: ''
destination:
description: 'Override destination branch'
default: ''
branch-suffix:
description: 'Branch suffix to append to PR branch name (to prevent collisions on multiple PRs/ticket)'
required: true
default: 'docs'
note:
description: 'Note for PR'
required: true
default: '<none>'
env:
GOPRIVATE: github.com/TykTechnologies
configInfoGeneratorBranch: main
jobs:
sanitize:
name: Sanitize inputs
runs-on: ubuntu-latest
outputs:
docsBranch: ${{ steps.collect.outputs.docsBranch }}
repoBranch: ${{ steps.collect.outputs.repoBranch }}
jira: ${{ steps.collect.outputs.jira }}
steps:
- name: Sanitize JIRA input
run: |
jira=$(echo '${{ github.event.inputs.jira }}' | sed -e 's/?.*//g' | xargs -n1 basename)
if [ "$jira" == *"-"* ]; then
echo "No valid JIRA ID found (no dash in JIRA ID)"
exit 1
fi
echo "jira=$jira" >> $GITHUB_ENV
- if: github.event.inputs.release == 'master'
run: |
echo "docsBranch=master" >> $GITHUB_ENV
echo "repoBranch=master" >> $GITHUB_ENV
- if: github.event.inputs.release == '5.0 LTS'
run: |
echo "docsBranch=release-5" >> $GITHUB_ENV
echo "repoBranch=release-5-lts" >> $GITHUB_ENV
- if: github.event.inputs.release == '5.1'
run: |
echo "docsBranch=release-5.1" >> $GITHUB_ENV
echo "repoBranch=release-5.1" >> $GITHUB_ENV
- if: github.event.inputs.release == '5.2'
run: |
echo "docsBranch=release-5.2" >> $GITHUB_ENV
echo "repoBranch=release-5.2" >> $GITHUB_ENV
- if: github.event.inputs.release == '5.3'
run: |
echo "docsBranch=release-5.3" >> $GITHUB_ENV
echo "repoBranch=release-5.3" >> $GITHUB_ENV
- if: github.event.inputs.source != ''
run: echo "repoBranch=${{ github.event.inputs.source }}" >> $GITHUB_ENV
- if: github.event.inputs.destination != ''
run: echo "docsBranch=${{ github.event.inputs.destination }}" >> $GITHUB_ENV
- id: collect
run: |
echo "jira=${{ env.jira }}" >> $GITHUB_OUTPUT
echo "docsBranch=${{ env.docsBranch }}" >> $GITHUB_OUTPUT
echo "repoBranch=${{ env.repoBranch }}" >> $GITHUB_OUTPUT
gateway:
needs: [sanitize]
name: Gateway docs
if: ${{ github.event.inputs.sync-gateway == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Gateway
uses: actions/checkout@v4.2.1
with:
fetch-depth: 1
repository: TykTechnologies/tyk
ref: ${{ needs.sanitize.outputs.repoBranch }}
path: ./tyk
- name: 'Extract tykio/ci-tools:latest'
uses: shrink/actions-docker-extract@v3.0.1
with:
image: tykio/ci-tools:latest
path: /usr/local/bin/.
destination: /usr/local/bin
- run: mkdir -p gateway-docs/
- name: Generate x-tyk-gateway docs
working-directory: ./tyk/apidef/oas
run: |
schema-gen extract -o - | schema-gen markdown -i - \
--root XTykAPIGateway \
--skip "OldOAS,APIDef,OAS,TykExtensionConfigParams" \
--title "## Tyk OAS API Definition Object" \
--replace "model.ObjectID=string,apidef.MiddlewareDriver=string,apidef.IdExtractorSource=string,apidef.IdExtractorType=string,apidef.RequestInputType=string,apidef.AuthTypeEnum=string,[]osin.AuthorizeRequestType=[]string" \
--heading-format "### **%s**" \
--trim "Tyk classic API definition" \
-o ../../../gateway-docs/x-tyk-gateway.md
- name: Generate docs
run: |
cp ./tyk/swagger.yml gateway-docs/gateway-swagger.yml
- name: Store docs
uses: actions/upload-artifact@v4.4.1
with:
name: gateway-docs
path: gateway-docs
dashboard:
needs: [sanitize]
name: Dashboard docs
if: ${{ github.event.inputs.sync-dashboard == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Dashboard
uses: actions/checkout@v4.2.1
with:
token: ${{ secrets.ORG_GH_TOKEN }}
fetch-depth: 1
repository: TykTechnologies/tyk-analytics
ref: ${{ needs.sanitize.outputs.repoBranch }}
path: ./tyk-analytics
- name: Generate docs
run: |
mkdir -p dashboard-docs/
cp ./tyk-analytics/swagger.yml dashboard-docs/dashboard-swagger.yml
cp ./tyk-analytics/swagger-admin.yml dashboard-docs/dashboard-admin-swagger.yml
- name: Store docs
uses: actions/upload-artifact@v4.4.1
with:
name: dashboard-docs
path: dashboard-docs
mdcb:
needs: [sanitize]
name: MDCB docs
if: ${{ github.event.inputs.sync-mdcb == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout MDCB
uses: actions/checkout@v4.2.1
with:
token: ${{ secrets.ORG_GH_TOKEN }}
fetch-depth: 1
repository: TykTechnologies/tyk-sink
ref: ${{ needs.sanitize.outputs.repoBranch }}
path: ./tyk-sink
- name: Generate docs
run: |
mkdir -p mdcb-docs/
cp ./tyk-sink/swagger.yml mdcb-docs/mdcb-swagger.yml
- name: Store docs
uses: actions/upload-artifact@v4.4.1
with:
name: mdcb-docs
path: mdcb-docs
configs:
needs: [sanitize]
name: Configuration docs
runs-on: ubuntu-latest
steps:
- name: Install Config Generator
uses: actions/checkout@v4.2.1
with:
repository: TykTechnologies/tyk-config-info-generator
path: ./tyk-config-info-generator
token: ${{ secrets.ORG_GH_TOKEN }}
ref: ${{ env.configInfoGeneratorBranch }}
- name: Set up env
run: |
mkdir -p $GITHUB_WORKSPACE/config-docs/
echo "repoBranch=${{ needs.sanitize.outputs.repoBranch }}" >> $GITHUB_ENV
echo "docsBranch=${{ needs.sanitize.outputs.docsBranch }}" >> $GITHUB_ENV
- name: Sync Gateway
working-directory: ./tyk-config-info-generator/src
if: ${{ github.event.inputs.sync-gateway == 'true' }}
run: |
repo=gateway
branch=$repoBranch
dest=$GITHUB_WORKSPACE/config-docs/$repo-config.md
sudo TOKEN=${{ secrets.ORG_GH_TOKEN }} node app.js $repo:$branch
cp /node/home/tyk-config-info-generator/info/$branch/gateway.md $dest
- name: Sync Dashboard
working-directory: ./tyk-config-info-generator/src
if: ${{ github.event.inputs.sync-dashboard == 'true' }}
run: |
repo=dashboard
branch=$repoBranch
dest=$GITHUB_WORKSPACE/config-docs/$repo-config.md
sudo TOKEN=${{ secrets.ORG_GH_TOKEN }} node app.js $repo:$branch
cp /node/home/tyk-config-info-generator/info/$branch/$repo.md $dest
- name: Sync Pump
working-directory: ./tyk-config-info-generator/src
if: ${{ github.event.inputs.sync-pump == 'true' }}
run: |
repo=pump
branch=${{ github.event.inputs.source || 'master' }}
dest=$GITHUB_WORKSPACE/config-docs/$repo-config.md
sudo TOKEN=${{ secrets.ORG_GH_TOKEN }} node app.js $repo:$branch
cp /node/home/tyk-config-info-generator/info/$branch/$repo.md $dest
- name: Sync MDCB
working-directory: ./tyk-config-info-generator/src
if: ${{ github.event.inputs.sync-mdcb == 'true' }}
run: |
repo=mdcb
branch=${{ github.event.inputs.source || 'master' }}
dest=$GITHUB_WORKSPACE/config-docs/$repo-config.md
sudo TOKEN=${{ secrets.ORG_GH_TOKEN }} node app.js $repo:$branch
cp /node/home/tyk-config-info-generator/info/$branch/$repo.md $dest
- name: Store docs
uses: actions/upload-artifact@v4.4.1
with:
name: config-docs
path: config-docs
finish:
name: Open PR against tyk-docs
needs: [sanitize, configs, dashboard, gateway]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Restore artifacts
uses: actions/download-artifact@v4.1.8
- name: Set up env
run: |
echo "jira=${{ needs.sanitize.outputs.jira }}" >> $GITHUB_ENV
echo "target=${{ needs.sanitize.outputs.docsBranch }}" >> $GITHUB_ENV
- name: Checkout Docs
uses: actions/checkout@v4.2.1
with:
fetch-depth: 1
repository: TykTechnologies/tyk-docs
path: ./tyk-docs
ref: ${{ needs.sanitize.outputs.docsBranch }}
- name: Write out docs
run: |
[ -d "gateway-docs" ] && cp gateway-docs/*.yml ./tyk-docs/tyk-docs/assets/others/
[ -d "gateway-docs" ] && cp gateway-docs/x-tyk-gateway.md ./tyk-docs/tyk-docs/content/shared/
[ -d "dashboard-docs" ] && cp dashboard-docs/*.yml ./tyk-docs/tyk-docs/assets/others/
[ -d "mdcb-docs" ] && cp mdcb-docs/*.yml ./tyk-docs/tyk-docs/assets/others/
[ -d "config-docs" ] && cp config-docs/* ./tyk-docs/tyk-docs/content/shared/
- name: Raise tyk-docs PR
uses: peter-evans/create-pull-request@v7.0.5
with:
token: ${{ secrets.ORG_GH_TOKEN }}
commit-message: Import config/docs
title: '[${{ env.jira }}] Update documentation for ${{ github.event.inputs.release }}'
body: |
Triggered by: ${{ github.actor }}
Included:
Tyk Gateway: ${{ github.event.inputs.sync-gateway }}
Tyk Dashboard: ${{ github.event.inputs.sync-dashboard }}
Tyk MDCB ${{ github.event.inputs.sync-mdcb }}
Tyk Pump ${{ github.event.inputs.sync-pump }}
Intended for: ${{ github.event.inputs.release }}
Changes sourced from: ${{ needs.sanitize.outputs.repoBranch }}
Config info generator branch: ${{ env.configInfoGeneratorBranch }}
Note: ${{ github.event.inputs.note }} (branch suffix: ${{ github.event.inputs.branch-suffix }})
JIRA: https://tyktech.atlassian.net/browse/${{ env.jira }}
branch: update/${{ env.jira }}/release-${{ env.target }}-${{ github.event.inputs.branch-suffix }}
path: ./tyk-docs
delete-branch: true