Enhance mkdocs.yml with theme toggles and extras #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Docs Site | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Generate script catalog | |
| run: | | |
| mkdir -p docs | |
| echo "# Script Catalog" > docs/script-catalog.md | |
| echo "Generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> docs/script-catalog.md | |
| echo "" >> docs/script-catalog.md | |
| echo "| Path | Size (KB) |" >> docs/script-catalog.md | |
| echo "|------|-----------|" >> docs/script-catalog.md | |
| git ls-files | grep -E '\.(sh|bash|ps1|bat)$' | while read -r f; do | |
| sz=$(wc -c < "$f") | |
| kb=$(awk -v s=$sz 'BEGIN{printf "%.2f", s/1024}') | |
| echo "| $f | $kb |" >> docs/script-catalog.md | |
| done | |
| - name: Convert markdown to HTML | |
| run: | | |
| set -e | |
| mkdir -p site | |
| if command -v pandoc >/dev/null 2>&1; then | |
| echo "Pandoc available" | |
| else | |
| sudo apt-get update -y && sudo apt-get install -y pandoc || echo "Pandoc install failed; using fallback" | |
| fi | |
| for md in docs/*.md; do | |
| base=$(basename "$md" .md) | |
| if command -v pandoc >/dev/null 2>&1; then | |
| pandoc "$md" -f markdown -t html5 -s -o "site/$base.html" | |
| else | |
| { | |
| echo "<html><head><meta charset='utf-8'><title>$base</title><style>body{font-family:Arial,Helvetica,sans-serif;max-width:860px;margin:40px auto;line-height:1.5;}table{border-collapse:collapse;}th,td{border:1px solid #ccc;padding:4px 8px;}code{background:#f5f5f5;padding:2px 4px;border-radius:3px;}a{color:#0366d6;text-decoration:none;}a:hover{text-decoration:underline;}</style></head><body>"; | |
| sed 's/^# \(.*\)/<h1>\1<\/h1>/' "$md" | sed 's/^## \(.*\)/<h2>\1<\/h2>/' | sed 's/^### \(.*\)/<h3>\1<\/h3>/' | |
| echo "</body></html>" | |
| } > "site/$base.html" | |
| fi | |
| done | |
| # Build index.html from index.md explicitly | |
| if [ -f docs/index.md ]; then | |
| if command -v pandoc >/dev/null 2>&1; then | |
| pandoc docs/index.md -f markdown -t html5 -s -o site/index.html | |
| else | |
| { | |
| echo "<html><head><meta charset='utf-8'><title>TRMM Scripts</title></head><body>"; | |
| sed 's/^# \(.*\)/<h1>\1<\/h1>/' docs/index.md | |
| echo "</body></html>"; | |
| } > site/index.html | |
| fi | |
| fi | |
| echo "Built pages:"; ls -1 site | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./site | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deploy | |
| uses: actions/deploy-pages@v4 |