name: Build and publish 3D Architecture Wizzard documentation on: push: branches: [test] pull_request: branches: [test] jobs: build: runs-on: ubuntu-latest container: node:20-bookworm steps: - name: Checkout exact revision shell: bash env: GIT_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REVISION: ${{ gitea.event.pull_request.head.sha || gitea.sha }} run: | set -euo pipefail test -n "$GIT_AUTH_TOKEN" test -n "$REVISION" git init . git remote add origin '${{ gitea.server_url }}/${{ gitea.repository }}.git' git -c http.extraheader="Authorization: token $GIT_AUTH_TOKEN" fetch --depth=1 origin "$REVISION" git checkout --detach FETCH_HEAD test "$(git rev-parse HEAD)" = "$REVISION" - name: Install pnpm run: npm install --global pnpm@10.15.1 - name: Install dependencies run: pnpm install --frozen-lockfile - name: Validate and build run: pnpm validate - name: Verify publication contract shell: bash run: | set -euo pipefail test -f build/index.html grep -Fq '3DARCH-PORTAL-KICKOFF-2026-08-31' build/index.html find build -maxdepth 1 -type f -name 'search-index*.json' -size +0c | grep -q . - name: Publish to Gondor Pages if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/test' shell: bash env: REVISION: ${{ gitea.sha }} run: | set -euo pipefail ORG_REPO='${{ gitea.repository }}' case "$ORG_REPO" in */*) ;; *) echo "invalid repository slug: $ORG_REPO" >&2; exit 1;; esac case "$ORG_REPO" in *..*|/*|*/|*//* ) echo "unsafe repository slug: $ORG_REPO" >&2; exit 1;; esac test -f build/index.html pages_root='/gondor-v1-gitea-pages' mountpoint -q "$pages_root" || { echo "$pages_root is not the persistent Pages mount" >&2; exit 1; } destination="$pages_root/$ORG_REPO" destination_parent="${destination%/*}" repository_name="${destination##*/}" staging="$destination_parent/.${repository_name}.staging-$REVISION" previous="$destination_parent/.${repository_name}.previous-$REVISION" rm -rf -- "$staging" "$previous" mkdir -p "$staging" cp -a build/. "$staging/" grep -Fq '3DARCH-PORTAL-KICKOFF-2026-08-31' "$staging/index.html" if test -e "$destination"; then mv -- "$destination" "$previous"; fi mv -- "$staging" "$destination" rm -rf -- "$previous"