406 lines (406 loc) · 15.4 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
name: Documentation
on:
push:
branches:
- master
repository_dispatch:
types:
- Update JS documentation
- Update C# documentation
- Update SDK documentation
- Update GTA documentation
jobs:
js:
runs-on: windows-2019
continue-on-error: true
steps:
- name: Conditional run
id: cond-run
run: |
if("${{ github.event.action }}" -ne "Update JS documentation") {
Write-Output "::set-output name=skip::true"
Write-Output "Step skipped."
}
- name: Setup Node.js
uses: actions/setup-node@v1
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
node-version: 12.x
- name: Checkout repository
uses: actions/checkout@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
persist-credentials: false
repository: altmp/altv-types
ref: ${{ github.event.client_payload.sha }}
path: ./altv-types
- name: Install dependencies
if: ${{ steps.cond-run.outputs.skip != 'true' }}
run: |
Set-Location -Path "./altv-types/docs/"
yarn install
- name: Generate JS metadata
if: ${{ steps.cond-run.outputs.skip != 'true' }}
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 "${{ github.event.client_payload.sha }}" --disableAlphabetOrder
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
name: js
path: ./altv-types/docs/
cs:
runs-on: windows-2019
continue-on-error: true
steps:
- name: Conditional run
id: cond-run
run: |
if("${{ github.event.action }}" -ne "Update C# documentation") {
Write-Output "::set-output name=skip::true"
Write-Host "Step skipped." -ForegroundColor "Red"
}
- name: Checkout repository
uses: actions/checkout@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
persist-credentials: false
repository: FabianTerhorst/coreclr-module
ref: ${{ github.event.client_payload.sha }}
path: ./coreclr-module
- name: Download DocFx package
uses: robinraju/release-downloader@v1
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
repository: dotnet/docfx
tag: v2.58
fileName: docfx.zip
- name: Unzip DocFx package
if: ${{ steps.cond-run.outputs.skip != 'true' }}
run: |
Expand-Archive -Path "./docfx.zip" -DestinationPath "./docfx/"
Remove-Item -Path "./docfx.zip"
- name: Generate C# metadata
if: ${{ steps.cond-run.outputs.skip != 'true' }}
run: ./docfx/docfx metadata "./coreclr-module/docs/docfx.json"
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
name: cs
path: ./coreclr-module/docs/
sdk:
runs-on: windows-2019
continue-on-error: true
steps:
- name: Conditional run
id: cond-run
run: |
if("${{ github.event.action }}" -ne "Update SDK documentation") {
Write-Output "::set-output name=skip::true"
Write-Host "Step skipped." -ForegroundColor "Red"
}
- name: Checkout repository
uses: actions/checkout@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
persist-credentials: false
repository: altmp/cpp-sdk
ref: ${{ github.event.client_payload.sha }}
path: ./cpp-sdk
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
name: sdk
path: ./cpp-sdk/articles/
gta:
runs-on: windows-latest
continue-on-error: true
steps:
- name: Conditional run
id: cond-run
run: |
if("${{ github.event.action }}" -ne "Update GTA documentation") {
Write-Output "::set-output name=skip::true"
Write-Output "Step skipped."
}
- name: Checkout repository
uses: actions/checkout@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
persist-credentials: false
repository: altmp/altv-docs-gta
ref: ${{ github.event.client_payload.sha }}
path: ./altv-docs-gta
- name: Install dependencies
if: ${{ steps.cond-run.outputs.skip != 'true' }}
run: exit 0
- name: Generate GTA metadata
if: ${{ steps.cond-run.outputs.skip != 'true' }}
run: exit 0
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ steps.cond-run.outputs.skip != 'true' }}
with:
name: gta
path: |
./altv-docs-gta/api
./altv-docs-gta/articles
docs:
runs-on: windows-2019
needs:
- js
- cs
- sdk
- gta
if: "contains(github.event.head_commit.message, 'Update documentation') || startsWith(github.event.action, 'Update')"
steps:
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Checkout JS repository
uses: actions/checkout@v2
with:
persist-credentials: false
repository: altmp/altv-types
path: ./altv-types
- name: Checkout C# repository
uses: actions/checkout@v2
with:
persist-credentials: false
repository: FabianTerhorst/coreclr-module
path: ./coreclr-module
- name: Checkout SDK repository
uses: actions/checkout@v2
with:
persist-credentials: false
repository: altmp/cpp-sdk
ref: docs
path: ./cpp-sdk
- name: Checkout GTA repository
uses: actions/checkout@v2
with:
persist-credentials: false
repository: altmp/altv-docs-gta
path: ./altv-docs-gta
- name: Checkout GTA assets repository
uses: actions/checkout@v2
with:
persist-credentials: false
repository: altmp/altv-docs-gta-assets
path: ./altv-docs-gta-assets
- name: Download DocFx package
uses: robinraju/release-downloader@v1
with:
repository: dotnet/docfx
tag: v2.58
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
with:
repository: Lhoerion/DocFx.Plugins.TypeScriptReference
tag: v1.1.5
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
with:
repository: Lhoerion/DocFx.Plugins.ExtractSearchIndex
tag: v1.0.2
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
with:
repository: Lhoerion/DocFx.Plugins.AddImageModal
tag: v0.0.2
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 DiscordFX package
uses: robinraju/release-downloader@v1
with:
repository: Lhoerion/DiscordFX
tag: v0.6.17
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 previous job artifacts
uses: actions/github-script@v4
with:
script: |
const AdmZip = require("adm-zip");
const fs = require("fs");
const path = require("path");
const artifactNames = ["js", "cs", "sdk", "gta"];
const artifacts = (await github.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.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 current job artifacts
uses: actions/download-artifact@v2
- name: Unpack artifacts
run: |
Remove-Item -Path "./altv-types/docs/" -Recurse
if(-not (Test-Path -Path "./js/js.tar")) {
Move-Item -Path "./js/" -Destination "./altv-types/docs"
} else {
Move-Item -Path "./js/js.tar" -Destination "./altv-types/js.tar"
tar -xvf "./altv-types/js.tar" -C "./altv-types/"
Remove-Item -Path "./altv-types/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 "./cs/cs.tar")) {
Move-Item -Path "./cs/" -Destination "./coreclr-module/docs"
} else {
Move-Item -Path "./cs/cs.tar" -Destination "./coreclr-module/cs.tar"
tar -xvf "./coreclr-module/cs.tar" -C "./coreclr-module/"
Remove-Item -Path "./coreclr-module/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 "./sdk/sdk.tar")) {
Move-Item -Path "./sdk/" -Destination "./cpp-sdk/articles"
} else {
Move-Item -Path "./sdk/sdk.tar" -Destination "./cpp-sdk/sdk.tar"
tar -xvf "./cpp-sdk/sdk.tar" -C "./cpp-sdk/"
Remove-Item -Path "./cpp-sdk/sdk.tar"
}
Remove-Item -Path "./altv-docs-gta/api/" -Recurse
Remove-Item -Path "./altv-docs-gta/articles/" -Recurse
if(-not (Test-Path -Path "./gta/gta.tar")) {
Move-Item -Path "./gta/api/" -Destination "./altv-docs-gta/api/"
Move-Item -Path "./gta/articles/" -Destination "./altv-docs-gta/articles/"
} else {
Move-Item -Path "./gta/gta.tar" -Destination "./altv-docs-gta/gta.tar"
tar -xvf "./altv-docs-gta/gta.tar" -C "./altv-docs-gta/"
Remove-Item -Path "./altv-docs-gta/gta.tar"
}
- name: Build docs
run: ./docfx/docfx "./docfx.json"
- name: Upload artifacts
uses: actions/upload-artifact@v2.2.4
with:
name: site
path: |
./_site/
!./_site/gta/images
deploy:
name: Deploy GitHub Pages
runs-on: ubuntu-20.04
needs:
- docs
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Checkout GTA assets repository
uses: actions/checkout@v2
with:
persist-credentials: false
repository: altmp/altv-docs-gta-assets
path: ./altv-docs-gta-assets
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: site
path: ./docs/_site
- name: Copy GTA assets to output site
run: |
Move-Item -Path "./altv-docs-gta-assets/images" -Destination "./docs/_site/gta/images"
- name: Deploy page
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_site
cname: docs.altv.mp
full_commit_message: Deploying to gh-pages from @ ${{ github.sha }} 🚀
- name: Post Download artifacts
if: ${{ always() }}
uses: geekyeggo/delete-artifact@v1
with:
name: site
- name: Download previous job artifacts
uses: actions/github-script@v4
with:
result-encoding: json
script: |
const fs = require("fs");
const path = require("path");
const artifactNames = ["js", "cs", "sdk", "gta"];
const artifacts = (await github.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 (let i = artifacts.length - 1; i >= 0; i--) {
const artifact = artifacts[i];
if (!artifact || artifacts.reduce((acc, val) => (val.name === artifact.name ? ++acc : acc), 0) <= 1) continue;
console.log("==> Artifact:", artifact.id);
console.log(`==> Removing: ${artifact.name}.zip (${(artifact.size_in_bytes / 1000000).toFixed(2)}MB)`);
await github.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id
});
artifact.name = null;
}