Deploy VitePress Documentation to GitHub Pages #6
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 VitePress Documentation to GitHub Pages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| triggered-by: | |
| description: "What triggered this workflow" | |
| required: false | |
| type: string | |
| default: "manual" | |
| dep-map-artifact: | |
| description: "Artifact name containing the dependency map JSON" | |
| required: false | |
| type: string | |
| default: "" | |
| source-repo: | |
| description: "Source repository (owner/repo) that triggered this workflow" | |
| required: false | |
| type: string | |
| default: "" | |
| source-run-id: | |
| description: "Source workflow run ID" | |
| required: false | |
| type: string | |
| default: "" | |
| node-version: | |
| description: 'Node.js version to use' | |
| required: false | |
| default: '24' | |
| type: string | |
| working-directory: | |
| description: 'Working directory for the TypeDoc generation' | |
| required: false | |
| default: '.' | |
| type: string | |
| src-path: | |
| description: 'Source path for TypeDoc (relative to working directory)' | |
| required: false | |
| default: 'src' | |
| type: string | |
| tsconfig-path: | |
| description: 'Path to tsconfig.json (relative to working directory)' | |
| required: false | |
| default: './src/tsconfig.json' | |
| type: string | |
| output-path: | |
| description: 'Output directory for generated docs' | |
| required: false | |
| default: 'docs/.vitepress/dist' | |
| type: string | |
| extra-typedoc-options: | |
| description: 'Extra TypeDoc CLI options' | |
| required: false | |
| default: '--entryPointStrategy expand' | |
| type: string | |
| install-dependencies: | |
| description: 'Whether to run pnpm install' | |
| required: false | |
| default: true | |
| type: boolean | |
| build-dependencies: | |
| description: 'Additional build dependencies to install' | |
| required: false | |
| default: '' | |
| type: string | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ${{ inputs.working-directory }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ inputs.node-version }} | |
| - name: Download dep-map artifact | |
| if: ${{ inputs.dep-map-artifact != '' && inputs.source-repo != '' && inputs.source-run-id != '' }} | |
| id: download-dep-map | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const [owner, repo] = '${{ inputs.source-repo }}'.split('/'); | |
| const fs = require('fs'); | |
| // Download artifact | |
| const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner, | |
| repo, | |
| run_id: ${{ inputs.source-run-id }} | |
| }); | |
| const artifact = artifacts.data.artifacts.find(a => a.name === '${{ inputs.dep-map-artifact }}'); | |
| if (!artifact) { | |
| throw new Error(`Artifact ${{ inputs.dep-map-artifact }} not found`); | |
| } | |
| const download = await github.rest.actions.downloadArtifact({ | |
| owner, | |
| repo, | |
| artifact_id: artifact.id, | |
| archive_format: 'zip' | |
| }); | |
| // Write and extract artifact | |
| fs.writeFileSync('artifact.zip', Buffer.from(download.data)); | |
| await exec.exec('unzip', ['-o', 'artifact.zip']); | |
| // Read the dep-map (file is always named dep-map.json inside the artifact) | |
| const depMap = JSON.parse(fs.readFileSync('dep-map.json', 'utf8')); | |
| console.log('📥 Downloaded dep-map from artifact:', depMap); | |
| // Output as JSON string | |
| core.setOutput('dep-map', JSON.stringify(depMap)); | |
| - name: Update dependencies | |
| if: ${{ inputs.dep-map-artifact != '' }} | |
| uses: arcmantle/github-actions/replace-deps@main | |
| with: | |
| dep-map: ${{ steps.download-dep-map.outputs.dep-map }} | |
| package-path: ${{ inputs.working-directory }}/package.json | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Install common build dependencies. | |
| run: pnpm add -D rimraf typescript @arcmantle/tsconfig @types/node ${{ inputs.additional-deps }} | |
| - name: Install TypeDoc globally | |
| run: pnpm add -g typedoc | |
| - name: Install project dependencies | |
| if: ${{ inputs.install-dependencies }} | |
| run: pnpm install | |
| - name: Build VitePress site | |
| run: pnpm docs:build | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ${{ inputs.working-directory }}/${{ inputs.output-path }} | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| name: Deploy | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |