Migrate docs to VitePress, add Bun/TypeScript book pipeline, harden CI #438
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: CI & Book Publication | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Verify | |
| run: vp run check | |
| docs: | |
| runs-on: ubuntu-latest | |
| needs: verify | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Build docs | |
| run: vp run docs:build | |
| - name: Configure Pages | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook' | |
| uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b | |
| # NOTE: This artifact is used for GitHub Pages deployment. The repository Pages source | |
| # must be switched from "gh-pages" branch to "GitHub Actions" only after this workflow goes green. | |
| - name: Upload Pages artifact | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook' | |
| uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa | |
| with: | |
| path: docs/.vitepress/dist | |
| manifest: | |
| runs-on: ubuntu-latest | |
| needs: verify | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Derive Variables | |
| run: | | |
| echo "BOOK_DATE=$(git log -1 --format=%cs)" >> $GITHUB_ENV | |
| echo "SOURCE_REVISION=${{ github.sha }}" >> $GITHUB_ENV | |
| - name: Assemble book & manifest | |
| run: vp run book:assemble | |
| - name: Upload Manifest and Manuscripts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | |
| with: | |
| name: manifest-manuscripts | |
| path: | | |
| dist/publication/manifest.json | |
| dist/publication/en/Plurality-english.md | |
| dist/publication/zh-TW/Plurality-traditional-mandarin.md | |
| legacy: | |
| runs-on: ubuntu-latest | |
| needs: manifest | |
| strategy: | |
| matrix: | |
| locale: [en, zh-TW] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Derive Variables | |
| run: | | |
| echo "BOOK_DATE=$(git log -1 --format=%cs)" >> $GITHUB_ENV | |
| echo "SOURCE_REVISION=${{ github.sha }}" >> $GITHUB_ENV | |
| - name: Render legacy output | |
| run: vp run book:legacy:${{ matrix.locale }} | |
| - name: Upload legacy artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | |
| with: | |
| name: legacy-${{ matrix.locale }} | |
| path: dist/publication/legacy | |
| legacy-validation: | |
| runs-on: ubuntu-latest | |
| needs: [manifest, legacy] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Download manifest and manuscripts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| name: manifest-manuscripts | |
| path: dist/publication | |
| - name: Download legacy artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| pattern: legacy-* | |
| path: dist/publication/legacy | |
| merge-multiple: true | |
| - name: Validate legacy outputs | |
| env: | |
| EXPECTED_SOURCE_REVISION: ${{ github.sha }} | |
| run: vp run book:legacy:validate | |
| candidate: | |
| runs-on: ubuntu-latest | |
| needs: manifest | |
| strategy: | |
| matrix: | |
| locale: [en, zh-TW] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install fonts | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y fonts-noto-cjk fonts-noto-color-emoji | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Derive Variables | |
| run: | | |
| echo "BOOK_DATE=$(git log -1 --format=%cs)" >> $GITHUB_ENV | |
| echo "SOURCE_REVISION=${{ github.sha }}" >> $GITHUB_ENV | |
| - name: Render candidate output | |
| run: vp run book:candidate:${{ matrix.locale }} | |
| - name: Upload candidate artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | |
| with: | |
| name: candidate-${{ matrix.locale }} | |
| path: dist/publication/candidate | |
| candidate-validation: | |
| runs-on: ubuntu-latest | |
| needs: [manifest, candidate] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb | |
| with: | |
| node-version: '24' | |
| cache: true | |
| run-install: false | |
| - name: Install dependencies (frozen) | |
| run: vp install --frozen-lockfile | |
| - name: Download manifest and manuscripts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| name: manifest-manuscripts | |
| path: dist/publication | |
| - name: Download candidate artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| pattern: candidate-* | |
| path: dist/publication/candidate | |
| merge-multiple: true | |
| - name: Validate candidate outputs | |
| env: | |
| EXPECTED_SOURCE_REVISION: ${{ github.sha }} | |
| run: vp run book:candidate:validate | |
| # NOTE: The GitHub Pages build/deployment source must be switched from the legacy "gh-pages" branch | |
| # to "GitHub Actions" in the repository settings ONLY after this workflow has run successfully and is green. | |
| # DO NOT mutate live Pages settings or push directly. | |
| deploy-pages: | |
| runs-on: ubuntu-latest | |
| needs: docs | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook' | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [legacy-validation, docs] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook' | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| - name: Download manifest and manuscripts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| name: manifest-manuscripts | |
| path: dist/publication | |
| - name: Download legacy artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | |
| with: | |
| pattern: legacy-* | |
| path: dist/publication/legacy | |
| merge-multiple: true | |
| - name: Create or Update GitHub Release | |
| uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd | |
| with: | |
| allowUpdates: true | |
| removeArtifacts: false | |
| replacesArtifacts: true | |
| artifactErrorsFailBuild: true | |
| tag: latest | |
| name: "Latest Book Release" | |
| artifacts: "dist/publication/manifest.json,dist/publication/legacy/Plurality-english.pdf,dist/publication/legacy/Plurality-english.epub,dist/publication/legacy/Plurality-traditional-mandarin.pdf,dist/publication/legacy/Plurality-traditional-mandarin.epub" | |
| webhook: | |
| runs-on: ubuntu-latest | |
| needs: [release, deploy-pages] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'pluralitybook' | |
| steps: | |
| - name: Send Rebuild Webhook | |
| env: | |
| REBUILD_WEBHOOK: ${{ secrets.REBUILD_WEBHOOK }} | |
| run: | | |
| curl --fail-with-body --retry 3 --retry-all-errors -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"revision\":\"${{ github.sha }}\",\"manifest_release_url\":\"https://github.com/${{ github.repository }}/releases/download/latest/manifest.json\",\"release_url\":\"https://github.com/${{ github.repository }}/releases/tag/latest\"}" \ | |
| "$REBUILD_WEBHOOK" |