-
Notifications
You must be signed in to change notification settings - Fork 50
553 lines (553 loc) · 20.8 KB
/
documentation.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
name: Documentation
on:
workflow_dispatch:
inputs:
environment:
description: 'Where to deploy changes'
required: true
default: 'dev'
type: choice
options:
- dev
- prod
regen-artifacts:
description: 'Regenerate artifacts (when expired or missing)'
required: false
type: boolean
repository_dispatch:
types:
- Update JS documentation
- Update C# documentation
- Update SDK documentation
- Update GTA documentation
env:
PRODUCTION: ${{ github.event.inputs.environment == 'prod' || github.event.action != '' }}
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
bootstrap:
runs-on: ubuntu-latest
outputs:
isSkipped: ${{ steps.cond-run.outputs.isSkipped }}
steps:
- name: Conditional run
id: cond-run
run: |
REGENERATE="${{ github.event.inputs.regen-artifacts }}"
ARTIFACTS=()
EVENT="${{ github.event.action }}"
declare -A ARTIFACTS_DEF=(
["Update JS documentation"]="js"
["Update C# documentation"]="cs"
["Update SDK documentation"]="sdk"
["Update GTA documentation"]="gta"
)
if [ "$REGENERATE" = "true" ]; then
echo "::set-output name=isSkipped::false"
exit
fi
for name in "${!ARTIFACTS_DEF[@]}"; do
if [[ "$EVENT" = "$name" ]]; then
ARTIFACTS+=("${ARTIFACTS_DEF[$name]}")
break
fi
done
echo "::set-output name=isSkipped::${ARTIFACTS[@]}"
js:
runs-on: windows-2019
needs: bootstrap
if: ${{ needs.bootstrap.outputs.isSkipped == 'false' || contains(needs.bootstrap.outputs.isSkipped, 'js') }}
env:
SOURCE_BRANCH: ${{ github.event.client_payload && github.event.client_payload.sha || 'master' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Load version manifest
uses: tw3lveparsecs/github-actions-setvars@v0.1
with:
envFilePath: ./.github/variables/vars.env
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/altv-types
ref: ${{ env.SOURCE_BRANCH }}
path: ./altv-types
- name: Checkout latest commit
run: git checkout $(git rev-parse HEAD)
working-directory: ./altv-types
- name: Install dependencies
run: |
Set-Location -Path "./altv-types/docs/"
yarn install
- name: Generate JS metadata
run: |
Set-Location -Path "./altv-types/docs/"
Push-Location -Path "../"
npx typedoc --options "./docs/typedoc.json"
Pop-Location
npx type2docfx "./api/.manifest" "./api/" --basePath "." --sourceUrl "https://github.com/altmp/altv-types" --sourceBranch "${{ env.SOURCE_BRANCH }}" --tocAlphabetOrderOnly
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'true'"
with:
name: js
path: ./altv-types/docs/
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'false'"
with:
name: nightly-js
path: ./altv-types/docs/
cs:
runs-on: windows-2019
needs: bootstrap
if: ${{ needs.bootstrap.outputs.isSkipped == 'false' || contains(needs.bootstrap.outputs.isSkipped, 'cs') }}
env:
SOURCE_BRANCH: ${{ github.event.client_payload && github.event.client_payload.sha || 'dev' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Load version manifest
uses: tw3lveparsecs/github-actions-setvars@v0.1
with:
envFilePath: ./.github/variables/vars.env
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: FabianTerhorst/coreclr-module
ref: ${{ env.SOURCE_BRANCH }}
path: ./coreclr-module
- name: Checkout latest commit
run: git checkout $(git rev-parse HEAD)
working-directory: ./coreclr-module
- name: Download DocFx package
uses: robinraju/release-downloader@v1.6
with:
repository: dotnet/docfx
tag: ${{ env.DOCFX }}
fileName: docfx.zip
- name: Unzip DocFx package
run: |
Expand-Archive -Path "./docfx.zip" -DestinationPath "./docfx/"
Remove-Item -Path "./docfx.zip"
- name: Generate C# metadata
run: ./docfx/docfx metadata "./coreclr-module/docs/docfx.json"
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'true'"
with:
name: cs
path: ./coreclr-module/docs/
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'false'"
with:
name: nightly-cs
path: ./coreclr-module/docs/
sdk:
runs-on: windows-2019
needs: bootstrap
if: ${{ needs.bootstrap.outputs.isSkipped == 'false' || contains(needs.bootstrap.outputs.isSkipped, 'sdk') }}
env:
SOURCE_BRANCH: ${{ github.event.client_payload && github.event.client_payload.sha || 'docs' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Load version manifest
uses: tw3lveparsecs/github-actions-setvars@v0.1
with:
envFilePath: ./.github/variables/vars.env
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/cpp-sdk
ref: ${{ env.SOURCE_BRANCH }}
path: ./cpp-sdk
- name: Checkout latest commit
run: git checkout $(git rev-parse HEAD)
working-directory: ./cpp-sdk
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'true'"
with:
name: sdk
path: ./cpp-sdk/articles/
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'false'"
with:
name: nightly-sdk
path: ./cpp-sdk/articles/
gta:
runs-on: windows-latest
needs: bootstrap
if: ${{ needs.bootstrap.outputs.isSkipped == 'false' || contains(needs.bootstrap.outputs.isSkipped, 'gta') }}
env:
SOURCE_BRANCH: ${{ github.event.client_payload && github.event.client_payload.sha || 'master' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Load version manifest
uses: tw3lveparsecs/github-actions-setvars@v0.1
with:
envFilePath: ./.github/variables/vars.env
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/altv-docs-gta
ref: ${{ env.SOURCE_BRANCH }}
path: ./altv-docs-gta
- name: Checkout latest commit
run: git checkout $(git rev-parse HEAD)
working-directory: ./altv-docs-gta
- name: Install dependencies
run: exit 0
- name: Generate GTA metadata
run: exit 0
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'true'"
with:
name: gta
path: |
./altv-docs-gta/api
./altv-docs-gta/articles
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'false'"
with:
name: nightly-gta
path: |
./altv-docs-gta/api
./altv-docs-gta/articles
docs:
runs-on: windows-2019
needs:
- js
- cs
- sdk
- gta
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Load version manifest
uses: tw3lveparsecs/github-actions-setvars@v0.1
with:
envFilePath: ./.github/variables/vars.env
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Checkout JS repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/altv-types
path: ./altv-types
- name: Checkout C# repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: FabianTerhorst/coreclr-module
path: ./coreclr-module
- name: Checkout SDK repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/cpp-sdk
ref: docs
path: ./cpp-sdk
- name: Checkout GTA repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/altv-docs-gta
path: ./altv-docs-gta
- name: Checkout assets repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/altv-docs-assets
ref: deploy
path: ./altv-docs-assets
- name: Download DocFx package
uses: robinraju/release-downloader@v1.6
with:
repository: dotnet/docfx
tag: ${{ env.DOCFX }}
fileName: docfx.zip
- name: Unzip DocFx package
run: |
Expand-Archive -Path "./docfx.zip" -DestinationPath "./docfx/"
Remove-Item -Path "docfx.zip"
- name: Download DocFx TypeScriptReference package
uses: robinraju/release-downloader@v1.6
with:
repository: Unnvaldr/DocFx.Plugins.TypeScriptReference
tag: ${{ env.DOCFX_PLUGINS_TYPESCRIPTREFERENCE }}
fileName: docfx-plugins-typescriptreference.zip
- name: Unzip DocFx TypeScriptReference package
run: |
Expand-Archive -Path "./docfx-plugins-typescriptreference.zip" -DestinationPath "./templates/"
Remove-Item -Path "./docfx-plugins-typescriptreference.zip"
- name: Download DocFx ExtractSearchIndex package
uses: robinraju/release-downloader@v1.6
with:
repository: Unnvaldr/DocFx.Plugins.ExtractSearchIndex
tag: ${{ env.DOCFX_PLUGINS_EXTRACTSEARCHINDEX }}
fileName: docfx-plugins-extractsearchindex.zip
- name: Unzip DocFx ExtractSearchIndex package
run: |
Expand-Archive -Path "./docfx-plugins-extractsearchindex.zip" -DestinationPath "./templates/"
Remove-Item -Path "./docfx-plugins-extractsearchindex.zip"
- name: Download DocFx AddImageModal package
uses: robinraju/release-downloader@v1.6
with:
repository: Unnvaldr/DocFx.Plugins.AddImageModal
tag: ${{ env.DOCFX_PLUGINS_ADDIMAGEMODAL }}
fileName: docfx-plugins-addimagemodal.zip
- name: Unzip DocFx AddImageModal package
run: |
Expand-Archive -Path "./docfx-plugins-addimagemodal.zip" -DestinationPath "./templates/"
Remove-Item -Path "./docfx-plugins-addimagemodal.zip"
- name: Download DocFx ExtractArticleAffix package
uses: robinraju/release-downloader@v1.6
with:
repository: Unnvaldr/DocFx.Plugins.ExtractArticleAffix
tag: ${{ env.DOCFX_PLUGINS_EXTRACTARTICLEAFFIX }}
fileName: docfx-plugins-extractarticleaffix.zip
- name: Unzip DocFx ExtractArticleAffix package
run: |
Expand-Archive -Path "./docfx-plugins-extractarticleaffix.zip" -DestinationPath "./templates/"
Remove-Item -Path "./docfx-plugins-extractarticleaffix.zip"
- name: Download DocFx DiscordFx package
uses: robinraju/release-downloader@v1.6
with:
repository: Unnvaldr/DiscordFx
tag: ${{ env.DOCFX_TMPLS_DISCORDFX }}
fileName: docfx-tmpls-discordfx.zip
- name: Unzip DocFx DiscordFx package
run: |
Expand-Archive -Path "./docfx-tmpls-discordfx.zip" -DestinationPath "./templates/"
Remove-Item -Path "./docfx-tmpls-discordfx.zip"
- run: npm install adm-zip
- name: Download latest artifacts
uses: actions/github-script@v6
with:
script: |
const AdmZip = require("adm-zip");
const fs = require("fs");
const path = require("path");
const isProduction = ${{ env.PRODUCTION }};
const devPrefix = !isProduction ? 'nightly-' : '';
const artifactNames = ["js", "cs", "sdk", "gta"].map(name => devPrefix + name);
const artifacts = (await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
})).data.artifacts;
if (!artifacts.length) {
console.log("No artifacts found");
return;
}
for (const artifact of artifactNames.map(el => artifacts.find(el2 => el2.name === el))) {
if (!artifact || artifact.expired) continue;
console.log("==> Artifact:", artifact.id);
console.log(`==> Downloading: ${artifact.name}.zip (${(artifact.size_in_bytes / 1000000).toFixed(2)}MB)`);
const zip = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: "zip"
});
const filePath = path.join("./", artifact.name);
const adm = new AdmZip(Buffer.from(zip.data));
adm.getEntries().forEach((entry) => {
const action = entry.isDirectory ? "creating" : "inflating";
console.log(` ${action}: ${path.join(filePath, entry.entryName)}`);
})
adm.extractAllTo(filePath, true);
}
- name: Download run artifacts
uses: actions/download-artifact@v3
- name: Unpack artifacts
run: |
$isProduction=$${{ env.PRODUCTION }}
$devPrefix=if (-not $isProduction) { 'nightly-' } else { '' }
Remove-Item -Path "./altv-types/docs/" -Recurse
if(-not (Test-Path -Path "./$($devPrefix)js/js.tar")) {
Move-Item -Path "./$($devPrefix)js/" -Destination "./altv-types/docs"
} else {
Move-Item -Path "./$($devPrefix)js/$($devPrefix)js.tar" -Destination "./altv-types/$($devPrefix)js.tar"
tar -xvf "./altv-types/$($devPrefix)js.tar" -C "./altv-types/"
Remove-Item -Path "./altv-types/$($devPrefix)js.tar"
}
if([System.String]::IsNullOrWhiteSpace((Get-Content -Path "altv-types\docs\api\.manifest" -ErrorAction SilentlyContinue))) {
throw "Invalid altv-types repo manifest."
}
Remove-Item -Path "./coreclr-module/docs/" -Recurse
if(-not (Test-Path -Path "./$($devPrefix)cs/$($devPrefix)cs.tar")) {
Move-Item -Path "./$($devPrefix)cs/" -Destination "./coreclr-module/docs"
} else {
Move-Item -Path "./$($devPrefix)cs/$($devPrefix)cs.tar" -Destination "./coreclr-module/$($devPrefix)cs.tar"
tar -xvf "./coreclr-module/$($devPrefix)cs.tar" -C "./coreclr-module/"
Remove-Item -Path "./coreclr-module/$($devPrefix)cs.tar"
}
if([System.String]::IsNullOrWhiteSpace((Get-Content -Path "coreclr-module\docs\api\.manifest" -ErrorAction SilentlyContinue))) {
throw "Invalid coreclr-module repo manifest."
}
Remove-Item -Path "./cpp-sdk/articles/" -Recurse
if(-not (Test-Path -Path "./$($devPrefix)sdk/$($devPrefix)sdk.tar")) {
Move-Item -Path "./$($devPrefix)sdk/" -Destination "./cpp-sdk/articles"
} else {
Move-Item -Path "./$($devPrefix)sdk/$($devPrefix)sdk.tar" -Destination "./cpp-sdk/$($devPrefix)sdk.tar"
tar -xvf "./cpp-sdk/$($devPrefix)sdk.tar" -C "./cpp-sdk/"
Remove-Item -Path "./cpp-sdk/$($devPrefix)sdk.tar"
}
Remove-Item -Path "./altv-docs-gta/api/" -Recurse
Remove-Item -Path "./altv-docs-gta/articles/" -Recurse
if(-not (Test-Path -Path "./$($devPrefix)gta/$($devPrefix)gta.tar")) {
Move-Item -Path "./$($devPrefix)gta/api/" -Destination "./altv-docs-gta/api/"
Move-Item -Path "./$($devPrefix)gta/articles/" -Destination "./altv-docs-gta/articles/"
} else {
Move-Item -Path "./$($devPrefix)gta/$($devPrefix)gta.tar" -Destination "./altv-docs-gta/$($devPrefix)gta.tar"
tar -xvf "./altv-docs-gta/$($devPrefix)gta.tar" -C "./altv-docs-gta/"
Remove-Item -Path "./altv-docs-gta/$($devPrefix)gta.tar"
}
- name: Build docs
run: ./docfx/docfx "./docfx.json"
- name: Prepare artifact
run: |
Remove-Item -Path "./_site/gta/images" -Recurse -Force
Compress-Archive -Path "./_site/" -DestinationPath "./site.zip"
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'true'"
with:
name: site
path: |
./site.zip
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: "env.PRODUCTION == 'false'"
with:
name: nightly-site
path: |
./site.zip
deploy:
name: Deploy GitHub Pages
runs-on: ubuntu-20.04
needs:
- docs
if: always() && needs.docs.result == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Checkout assets repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: altmp/altv-docs-assets
path: ./altv-docs-assets
- name: Download artifact
uses: actions/download-artifact@v3
if: "env.PRODUCTION == 'true'"
with:
name: site
path: "."
- name: Download artifact
uses: actions/download-artifact@v3
if: "env.PRODUCTION == 'false'"
with:
name: nightly-site
path: "."
- name: Prepare artifact
run: |
unzip "./site.zip"
- name: Copy assets to output site
run: |
shopt -s dotglob # Obligatory
DOCFX_CFG=$(cat "./docfx.json")
find "altv-docs-assets/" -mindepth 1 -maxdepth 1 -type "d" ! -name '.*' -print0 | while read -d $'\0' file
do
DEST=$(echo "$DOCFX_CFG" | jq -r --arg path "$file" '.build .resource[] | select(.src==$path) | .dest')
if [ -n "$DEST" ]; then
echo "Destination path \"$DEST\" found for \"$file\""
for dir in "$file"/*; do
dirDest="./_site/$DEST/"$(basename "$dir")
if [ ! -d "$dirDest" ]; then
mkdir "$dirDest"
fi
mv "$dir"/* "$dirDest"
done
else
echo "Destination path not found for \"$file\""
fi
done
ls -Rl ./_site/*/images
- name: Deploy page
uses: peaceiris/actions-gh-pages@v3
if: "env.PRODUCTION == 'true'"
with:
deploy_key: ${{ secrets.RELEASE_PRIVATE_KEY }}
publish_dir: ./_site
external_repository: altmp/altv-docs-release
full_commit_message: Deploying to gh-pages from @ ${{ github.sha }} 🚀
force_orphan: false
cname: docs.altv.mp
- name: Deploy page
uses: peaceiris/actions-gh-pages@v3
if: "env.PRODUCTION == 'false'"
with:
deploy_key: ${{ secrets.NIGHTLY_PRIVATE_KEY }}
publish_dir: ./_site
external_repository: altmp/altv-docs-nightly
full_commit_message: Deploying to gh-pages from @ ${{ github.sha }} 🚀
force_orphan: false
- name: Post Download artifacts
if: ${{ always() }}
uses: geekyeggo/delete-artifact@v2
with:
name: site
- name: Purge older artifacts
uses: Unnvaldr/actions-purge-artifacts@master
if: "env.PRODUCTION == 'true'"
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
expire_strategy: 1
artifact_name: |
js
cs
sdk
gta
- name: Purge older artifacts
uses: Unnvaldr/actions-purge-artifacts@master
if: "env.PRODUCTION == 'false'"
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
expire_strategy: 1
artifact_name: |
nightly-js
nightly-cs
nightly-sdk
nightly-gta