Deploy Documentation #26
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 Documentation | |
| # ── Triggers ────────────────────────────────────────────────────────────────── | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'apps/**' | |
| - 'packages/**' | |
| - 'pnpm-lock.yaml' | |
| - 'pnpm-workspace.yaml' | |
| - '.github/workflows/deploy.yml' | |
| # Rebuild every Monday 08:00 UTC to refresh GitHub module data | |
| schedule: | |
| - cron: '0 8 * * 1' | |
| # Allow manual trigger from the GitHub UI | |
| workflow_dispatch: | |
| # ── Permissions (required for Pages deployment) ─────────────────────────────── | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # ── Only one deployment at a time ───────────────────────────────────────────── | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| # ── Jobs ────────────────────────────────────────────────────────────────────── | |
| jobs: | |
| build: | |
| name: Build Docs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v5 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build all docs sites | |
| env: | |
| # Provides 5 000 req/hr GitHub API limit for module ecosystem data | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: pnpm build:all | |
| # ── Debug: show what Astro produced ──────────────────────────────────── | |
| # Remove this step once the first deploy is confirmed working. | |
| - name: Show dist structure | |
| run: | | |
| echo "=== docs-27/dist ===" | |
| find apps/docs-27/dist -maxdepth 4 -type f | sort | head -30 | |
| echo "=== docs-4x/dist ===" | |
| find apps/docs-4x/dist -maxdepth 4 -type f | sort | head -20 | |
| # ── Merge both build outputs into one deploy folder ───────────────────── | |
| # | |
| # How Astro 6 static output works with base: | |
| # base: '/xoops-docs/2.7' → files land in dist/xoops-docs/2.7/ | |
| # base: '/xoops-docs/4.x' → files land in dist/xoops-docs/4.x/ | |
| # | |
| # We strip the leading 'xoops-docs/' so dist-all/ contains 2.7/ and 4.x/. | |
| # GitHub Pages serves the repo at /xoops-docs/, so: | |
| # dist-all/2.7/index.html → https://xoops.github.io/xoops-docs/2.7/ | |
| # dist-all/4.x/index.html → https://xoops.github.io/xoops-docs/4.x/ | |
| - name: Merge build outputs | |
| run: | | |
| mkdir -p dist-all | |
| # Copy nested base-path content out one level | |
| if [ -d "apps/docs-27/dist/xoops-docs" ]; then | |
| cp -r apps/docs-27/dist/xoops-docs/. dist-all/ | |
| else | |
| echo "WARNING: docs-27 dist/xoops-docs not found — falling back to flat copy" | |
| mkdir -p dist-all/2.7 | |
| cp -r apps/docs-27/dist/. dist-all/2.7/ | |
| fi | |
| if [ -d "apps/docs-4x/dist/xoops-docs" ]; then | |
| cp -r apps/docs-4x/dist/xoops-docs/. dist-all/ | |
| else | |
| echo "WARNING: docs-4x dist/xoops-docs not found — falling back to flat copy" | |
| mkdir -p dist-all/4.x | |
| cp -r apps/docs-4x/dist/. dist-all/4.x/ | |
| fi | |
| # Root redirect: /xoops-docs/ → /xoops-docs/2.7/ | |
| cat > dist-all/index.html << 'EOF' | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta http-equiv="refresh" content="0; url=/xoops-docs/2.7/" /> | |
| <title>XOOPS Docs</title> | |
| </head> | |
| <body> | |
| Redirecting to <a href="/xoops-docs/2.7/">XOOPS 2.7 Docs</a>… | |
| </body> | |
| </html> | |
| EOF | |
| echo "=== dist-all layout ===" | |
| find dist-all -maxdepth 3 -type f | sort | head -30 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: dist-all/ | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |