Skip to content

xd

xd #2212

Workflow file for this run

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%%/*}
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"
rawf=$(grep -Po 'MODULE\.Features\s*=\s*(\{[^}]*\}|"[^"]*")' "$m" | head -n1 | sed -E 's/^[^=]+=\s*//' || true)
raww=$(grep -Po 'MODULE\.WorkshopContent\s*=\s*(\{[^}]*\}|"[^"]*")' "$m" | head -n1 | sed -E 's/^[^=]+=\s*//' || true)
feat=$(parse_list "$rawf")
work=$(parse_list "$raww")
# Use the actual directory name for the folder path (not the display name)
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 "https://liliaframework.github.io/modules/${folder}/about/" \
--argjson features "$feat" \
--argjson workshop "$work" \
'. += [{name:$name,versionID:$versionID,author:$author,discord:$discord,description:$desc,version:$version,download:$download,source:$source,features:$features,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/about.md"
echo "Copied $readme_file to $dest/about.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
# Generate modules.md in the docs directory
echo '# List of Modules' > documentation/docs/modules.md
echo "" >> documentation/docs/modules.md
# Check if modules.json exists and generate index
if [ -f "documentation/modules.json" ]; then
echo "Generating module index from modules.json..."
jq -r '
sort_by(.name) |
.[] |
@text "## [\(.name)](\(.source))\n\(.description // "No description available")\n"
' documentation/modules.json >> documentation/docs/modules.md
# Also generate an index.md inside docs/modules for directory-style index
echo '# Modules' > documentation/docs/modules/index.md
echo "" >> documentation/docs/modules/index.md
jq -r '
sort_by(.name) |
.[] |
@text "- [\(.name)](\(.source))\n"
' documentation/modules.json >> documentation/docs/modules/index.md
else
echo "Warning: modules.json not found, creating basic index..."
echo "No module data available. Please check back later." >> documentation/docs/modules.md
echo "# Modules" > documentation/docs/modules/index.md
echo "No module data available. Please check back later." >> documentation/docs/modules/index.md
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