-
Notifications
You must be signed in to change notification settings - Fork 3
471 lines (450 loc) · 17.8 KB
/
Copy pathci.yml
File metadata and controls
471 lines (450 loc) · 17.8 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
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
name: CI
on:
push:
branches:
- main
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: modules
- uses: leafo/gh-actions-lua@v8.0.0
with:
luaVersion: 5.2
- uses: leafo/gh-actions-luarocks@v4.0.0
- uses: actions/checkout@v3
with:
repository: LiliaFramework/GluaCheck
path: luacheck
- run: luarocks make
working-directory: luacheck
- run: |
luacheck . \
--no-redefined \
--no-global --no-self \
--no-max-line-length --no-max-code-line-length \
--no-max-string-line-length --no-max-comment-line-length
working-directory: modules
scrape-modules:
needs: linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: sudo apt-get update && sudo apt-get install -y jq zip
- name: extract-module-metadata
shell: bash
run: |
set -euo pipefail
parse_list() {
local s="$1"
[ -z "$s" ] && { printf '[]'; return; }
if [[ $s == \{* ]]; then
s=$(echo "$s" | tr -d '\n' | sed -E 's/^\{//;s/\}$//')
IFS=',' read -ra arr <<< "$s"
printf '['
for idx in "${!arr[@]}"; do
entry=$(echo "${arr[$idx]}" | sed -E 's/^\s*"|"\s*$//g')
printf '"%s"' "$entry"
[ "$idx" -lt $(( ${#arr[@]} - 1 )) ] && printf ','
done
printf ']'
else
s=$(echo "$s" | sed -E 's/^\s*"|"\s*$//g')
[ -z "$s" ] && { printf '[]'; return; }
printf '["%s"]' "$s"
fi
}
echo '[]' > modules_data.json
for m in */module.lua; do
[ -f "$m" ] || continue
dir=${m%%/*}
# Initialize variables to prevent leakage between iterations
name_key=""
uniqueid=""
author=""
discord=""
desc_key=""
name=""
desc=""
version=""
rawf=""
raww=""
feat=""
work=""
folder=""
name_key=$(grep -Po 'MODULE\.name\s*=\s*"[^"]*"' "$m" | sed -E 's/.*=\s*"([^"]+)".*/\1/' || true)
uniqueid=$(grep -Po 'MODULE\.versionID\s*=\s*"[^"]*"' "$m" | sed -E 's/.*=\s*"([^"]+)".*/\1/' || true)
author=$(grep -Po 'MODULE\.author\s*=\s*"[^"]*"' "$m" | sed -E 's/.*=\s*"([^"]+)".*/\1/' || true)
discord=$(grep -Po 'MODULE\.discord\s*=\s*"[^"]*"' "$m" | sed -E 's/.*=\s*"([^"]+)".*/\1/' || true)
desc_key=$(grep -Po 'MODULE\.desc\s*=\s*"[^"]*"' "$m" | sed -E 's/.*=\s*"([^"]+)".*/\1/' || true)
lang_file="$dir/languages/english.lua"
if [ -f "$lang_file" ]; then
name=$(grep -Po "\\b${name_key}\\s*=\\s*\"\\K[^\"]*" "$lang_file" | head -n1 || true)
desc=$(grep -Po "\\b${desc_key}\\s*=\\s*\"\\K[^\"]*" "$lang_file" | head -n1 || true)
fi
[ -z "$name" ] && name="$name_key"
[ -z "$desc" ] && desc="$desc_key"
version=$(grep -Po 'MODULE\.version\s*=\s*[0-9]+(\.[0-9]{2})?' "$m" | sed -E 's/.*=\s*//' || true)
[ -z "$version" ] && version="0.00"
raww=$(grep -Po 'MODULE\.WorkshopContent\s*=\s*(\{[^}]*\}|"[^"]*")' "$m" | head -n1 | sed -E 's/^[^=]+=\s*//' || true)
work=$(parse_list "$raww")
# Generate slug for anchor
slug=$(echo "$name" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g' | sed -E 's/^-+|-+$//g')
folder="$dir"
jq --arg name "$name" \
--arg versionID "$uniqueid" \
--arg author "$author" \
--arg discord "$discord" \
--arg desc "$desc" \
--arg version "$version" \
--arg download "https://github.com/LiliaFramework/Modules/raw/refs/heads/gh-pages/${dir}.zip" \
--arg source "../modules/index.md#${slug}" \
--arg folder "$folder" \
--argjson workshop "$work" \
'. += [{name:$name,versionID:$versionID,author:$author,discord:$discord,description:$desc,version:$version,download:$download,source:$source,folder:$folder,workshop:$workshop}]' modules_data.json > tmp.json
mv tmp.json modules_data.json
done
- name: zip-modules
shell: bash
run: |
for d in */; do
[ -d "$d" ] && zip -r "${d%/}.zip" "$d"
done
- name: run-scrap-script
run: node scrap_modules.js
- name: move-json
run: mv modules_data.json modules.json
- uses: actions/upload-artifact@v4
with:
name: module-zips
path: ./*.zip
- uses: actions/upload-artifact@v4
with:
name: modules-json
path: modules.json
- name: debug-scrape-modules-complete
run: |
echo "=== SCRAPE-MODULES JOB COMPLETED ==="
echo "Artifacts uploaded:"
echo "- module-zips: $(ls -la *.zip | wc -l) zip files"
echo "- modules-json: modules.json"
echo "Job completed successfully"
gh-pages:
needs: scrape-modules
runs-on: ubuntu-latest
steps:
- name: debug-gh-pages-start
run: |
echo "=== GH-PAGES JOB STARTED ==="
echo "Current working directory: $(pwd)"
echo "Directory contents:"
ls -la
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: debug-after-checkout
run: |
echo "=== AFTER CHECKOUT ==="
echo "Current working directory: $(pwd)"
echo "Directory contents:"
ls -la
- name: create-docs-dir
run: mkdir -p documentation
- name: debug-after-create-docs
run: |
echo "=== AFTER CREATE DOCS DIR ==="
echo "Documentation directory created:"
ls -la documentation/
- uses: actions/download-artifact@v4
with:
name: module-zips
path: documentation
- name: debug-after-download-zips
run: |
echo "=== AFTER DOWNLOAD ZIPS ==="
echo "Documentation directory contents:"
ls -la documentation/
- uses: actions/download-artifact@v4
with:
name: modules-json
path: documentation
- name: debug-after-download-json
run: |
echo "=== AFTER DOWNLOAD JSON ==="
echo "Documentation directory contents:"
ls -la documentation/
- name: unzip-modules
shell: bash
run: |
for z in documentation/*.zip; do
f=$(basename "$z" .zip)
unzip "$z" -d "extracted_${f}"
done
- name: debug-after-unzip
run: |
echo "=== AFTER UNZIP ==="
echo "Current directory contents:"
ls -la
echo "Extracted directories:"
ls -la extracted_* || echo "No extracted directories found"
- name: gather-module-docs
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
for d in extracted_*; do
[ -d "$d" ] || continue
mod=${d#extracted_}
echo "Processing module: $mod (directory: $d)"
echo "Contents of $d:"
ls -la "$d/" | head -10
# Use the actual directory name for the folder path (not the display name)
folder="$mod"
dest="documentation/docs/modules/${folder}"
mkdir -p "$dest"
# Copy module's README.md as about.md
# Try multiple possible locations and case variations
readme_file=""
if [ -f "$d/README.md" ]; then
readme_file="$d/README.md"
elif [ -f "$d/readme.md" ]; then
readme_file="$d/readme.md"
else
# Look for README in subdirectories (max depth 1)
readme_file=$(find "$d" -maxdepth 2 -type f \( -iname "readme.md" -o -iname "readme.txt" \) | head -n 1 || true)
fi
if [ -n "$readme_file" ] && [ -f "$readme_file" ]; then
cp "$readme_file" "$dest/index.md"
echo "Copied $readme_file to $dest/index.md for module $mod"
else
echo "No README found for module $mod in $d"
fi
# Copy existing docs if they exist
doc_dir=$(find "$d" -type d -iname docs -maxdepth 2 -print -quit || true)
if [ -n "$doc_dir" ]; then
find "$doc_dir" -maxdepth 1 -type f -name '*.md' -exec cp {} "$dest/" \;
# Look for changelog files in docs folder
changelog_file=""
for possible_changelog in "$doc_dir/CHANGELOG.md" "$doc_dir/changelog.md" "$doc_dir/CHANGELOG.txt" "$doc_dir/changelog.txt" "$doc_dir/HISTORY.md" "$doc_dir/history.md"; do
if [ -f "$possible_changelog" ]; then
changelog_file="$possible_changelog"
break
fi
done
# Also check for changelog files in module root if not found in docs
if [ -z "$changelog_file" ]; then
for possible_changelog in "$d/CHANGELOG.md" "$d/changelog.md" "$d/CHANGELOG.txt" "$d/changelog.txt" "$d/HISTORY.md" "$d/history.md"; do
if [ -f "$possible_changelog" ]; then
changelog_file="$possible_changelog"
break
fi
done
fi
# Copy changelog with standard name if found
if [ -n "$changelog_file" ]; then
cp "$changelog_file" "$dest/changelog.md"
echo "Copied changelog from $changelog_file to $dest/changelog.md for module $mod"
fi
fi
done
shopt -u nullglob
- name: generate-modules-md
shell: bash
run: |
set -euo pipefail
# Ensure the docs directory exists
mkdir -p documentation/docs/modules
# Ensure the documentation directory exists
mkdir -p documentation/docs
# Run the Node.js script to generate modules.md and modules/index.md
if [ -f "generate_module_docs.js" ]; then
node generate_module_docs.js
# Cleanup individual module folders now that they are combined into the index
# This prevents files from being "split" across multiple directories
find documentation/docs/modules/ -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +
else
echo "Error: generate_module_docs.js not found"
ls -la
exit 1
fi
- name: debug-after-gather-docs
run: |
echo "=== AFTER GATHER MODULE DOCS ==="
echo "Documentation directory structure:"
find documentation -type f -name "*.md" | head -10
echo "Documentation directory contents:"
ls -la documentation/
- name: prepare-artifact-for-upload
run: |
echo "Current directory contents:"
ls -la
echo "Documentation directory contents:"
ls -la documentation/ || echo "Documentation directory does not exist"
echo "Creating artifact copy..."
cp -r documentation built-docs-artifact
echo "Artifact copy created:"
ls -la built-docs-artifact/
- name: verify-artifact-before-upload
run: |
echo "Verifying artifact before upload:"
ls -la built-docs-artifact/
echo "File count in artifact:"
find built-docs-artifact -type f | wc -l
- uses: actions/upload-artifact@v4
with:
name: built-docs
path: built-docs-artifact
- name: verify-artifact-upload
run: |
echo "Artifact upload completed successfully"
echo "Artifact path was: built-docs-artifact"
- name: clean-obsolete-docs
run: |
rm -rf documentation/docs/hooks/modules
rm -rf documentation/docs/libraries/modules
- name: remove-docs-before-publish
run: rm -rf documentation/docs
- name: remove-modules-json-before-publish
run: rm -f documentation/modules.json
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.LiliaGitSecret }}
publish_branch: gh-pages
publish_dir: documentation
force_orphan: true
upload-docs:
needs: gh-pages
runs-on: ubuntu-latest
steps:
- name: debug-upload-docs-start
run: |
echo "=== UPLOAD-DOCS JOB STARTED ==="
echo "This job depends on gh-pages job"
echo "Current working directory: $(pwd)"
echo "Directory contents:"
ls -la
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: debug-after-checkout
run: |
echo "=== AFTER CHECKOUT ==="
echo "Current working directory: $(pwd)"
echo "Directory contents:"
ls -la
- name: debug-before-download
run: |
echo "About to download built-docs artifact"
echo "Current directory contents:"
ls -la
- uses: actions/download-artifact@v4
with:
name: built-docs
path: built-docs
- name: debug-after-download
run: |
echo "Download completed. Checking if built-docs exists:"
ls -la built-docs/ || echo "built-docs directory does not exist after download"
echo "Checking docs directory contents:"
ls -la built-docs/docs/ || echo "built-docs/docs directory does not exist"
echo "Checking if documentation directory exists:"
ls -la built-docs/documentation/ || echo "built-docs/documentation directory does not exist"
- name: debug-artifact-contents
run: |
echo "Contents of built-docs directory:"
ls -la built-docs/ || echo "built-docs directory does not exist"
echo "Contents of built-docs/documentation directory:"
ls -la built-docs/documentation/ || echo "built-docs/documentation directory does not exist"
- name: create-module-markdown-branch
shell: bash
run: |
set -euo pipefail
git config user.email "githubactions@github.com"
git config user.name "GitHub Actions"
# Create or switch to module-markdown branch
if git show-ref --verify --quiet refs/heads/module-markdown; then
echo "Branch module-markdown exists locally, checking it out"
git checkout module-markdown
# Remove all existing files to start clean
git rm -rf . || true
git clean -fd || true
else
echo "Branch module-markdown does not exist locally, creating it"
git checkout --orphan module-markdown
# Remove all files from the orphan branch
git rm -rf . || true
fi
- name: copy-built-docs
shell: bash
run: |
set -euo pipefail
mkdir -p documentation
# Check if built-docs exists and has content
if [ ! -d "built-docs" ]; then
echo "Error: built-docs directory does not exist"
exit 1
fi
# Check what's actually in the artifact
echo "Built-docs contents:"
find built-docs -type f \( -name "*.md" -o -name "*.json" \) | sed -n '1,10p' || true
# Copy documentation if it exists
echo "Checking directory structure..."
echo "built-docs/documentation exists: $([ -d "built-docs/documentation" ] && echo "YES" || echo "NO")"
echo "built-docs/docs exists: $([ -d "built-docs/docs" ] && echo "YES" || echo "NO")"
if [ -d "built-docs/documentation" ]; then
echo "Copying from built-docs/documentation/"
rsync -a built-docs/documentation/ documentation/
elif [ -d "built-docs/docs" ]; then
echo "Copying from built-docs/docs/"
rsync -a built-docs/docs/ documentation/
else
echo "Copying from built-docs/"
rsync -a built-docs/ documentation/
fi
echo "Copy completed. Documentation directory contents:"
ls -la documentation/ || echo "Documentation directory does not exist"
# Also copy modules.json if it exists
if [ -f "built-docs/modules.json" ]; then
echo "Copying modules.json"
cp built-docs/modules.json documentation/
fi
mkdir -p documentation/docs/versioning
if [ -f documentation/modules.json ]; then
mv documentation/modules.json documentation/docs/versioning/modules.json
fi
- name: commit-push-docs
shell: bash
run: |
set -euo pipefail
echo "Current directory contents before commit:"
ls -la
echo "Documentation directory contents:"
ls -la documentation/ || echo "Documentation directory does not exist"
# Only add the documentation directory
git add documentation/
if git diff --cached --quiet; then
echo "No documentation changes to commit"
else
echo "Committing documentation changes..."
git commit -m "Updated Some Public Modules"
echo "Force pushing to module-markdown branch..."
git push --force origin "module-markdown"
fi