diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c77e2e1..c8805b4 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,6 +20,7 @@ jobs: environment: name: github-pages url: ${{ steps.deploy.outputs.page_url }} + steps: - name: Checkout (shallow) uses: actions/checkout@v4 @@ -29,42 +30,152 @@ jobs: - name: Configure Pages uses: actions/configure-pages@v5 - - name: Aggregate files from all branches into ./public + - name: Aggregate and build recursive directory pages shell: bash run: | set -euo pipefail + + # jq for JSON escaping (present on runners, but ensure) + if ! command -v jq >/dev/null 2>&1; then + sudo apt-get update -y + sudo apt-get install -y jq + fi + + REPO="${GITHUB_REPOSITORY#*/}" + SITE_ROOT="/${REPO}/" + mkdir -p public + : > public/.nojekyll - # List remote branches (exclude HEAD pointer) - mapfile -t BRANCHES < <(git ls-remote --heads origin \ - | awk '{print $2}' | sed 's@refs/heads/@@') + # Tiny favicon assets to avoid 404s + printf "%s" \ + "🚀" \ + > public/favicon.svg - # Minimal index page + # List remote branches + mapfile -t BRANCHES < <( + git ls-remote --heads origin | awk '{print $2}' \ + | sed 's@refs/heads/@@' + ) + + # Landing page (no globals except window.__branches) cat > public/index.html <<'HTML' - - Branches

Branches

" >> public/index.html - echo "Built public/ for ${#BRANCHES[@]} branches." + + # Finish landing page + cat >> public/index.html <<'HTML' + + HTML - name: Upload Pages artifact uses: actions/upload-pages-artifact@v4 @@ -73,4 +184,4 @@ jobs: - name: Deploy to GitHub Pages id: deploy - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v4 \ No newline at end of file