Fix docs links for GitHub browsing (#689) #580
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: gh-pages | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| env: | |
| RUSTFLAGS: -D warnings | |
| jobs: | |
| gh-pages: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: rustdoc | |
| run: make doc | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: design/package-lock.json | |
| - name: Install Docusaurus dependencies | |
| run: cd design && npm ci | |
| - name: Build Docusaurus site | |
| run: cd design && npm run build | |
| - name: Stage build artifacts | |
| run: | | |
| mkdir -p site | |
| mv ./target/doc site/rustdoc | |
| mv design/build site/design | |
| # We deploy with `force_orphan: true` so the gh-pages branch stays a | |
| # single orphan commit (no history accumulation), but that wipes the | |
| # branch contents — which would blow away the `pr-preview/` directory | |
| # the .github/workflows/pages-preview.yaml workflow writes there. | |
| # | |
| # To keep both properties (single-commit history + live PR previews), | |
| # we explicitly fetch any existing `pr-preview/` from gh-pages and | |
| # carry it into the deploy folder so it round-trips through the | |
| # orphan rewrite. | |
| - name: Preserve pr-preview directories from prior gh-pages | |
| run: | | |
| set -euo pipefail | |
| if git fetch origin gh-pages --depth=1 2>/dev/null; then | |
| git worktree add /tmp/gh-pages-prev origin/gh-pages | |
| if [ -d /tmp/gh-pages-prev/pr-preview ]; then | |
| cp -R /tmp/gh-pages-prev/pr-preview site/pr-preview | |
| echo "Preserved $(ls /tmp/gh-pages-prev/pr-preview | wc -l | tr -d ' ') PR preview directory(ies)" | |
| else | |
| echo "No pr-preview/ directory on gh-pages — nothing to preserve" | |
| fi | |
| git worktree remove --force /tmp/gh-pages-prev | |
| else | |
| echo "gh-pages branch does not exist yet — fresh deploy" | |
| fi | |
| - name: Deploy Docs | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_branch: gh-pages | |
| publish_dir: ./site | |
| force_orphan: true |