|
| 1 | +name: 'Build and deploy docs' |
| 2 | +description: >- |
| 3 | + Build the VitePress docs site (which bundles install.sh / install.ps1 into |
| 4 | + its public assets) and deploy it to a void.app project. Run on a Linux |
| 5 | + runner after checkout. See rfcs/deploy-docs-on-release.md for which |
| 6 | + workflow deploys to which project. |
| 7 | +
|
| 8 | +inputs: |
| 9 | + void-project: |
| 10 | + description: 'void.app project to deploy to (e.g. viteplus, viteplus-main).' |
| 11 | + required: true |
| 12 | + void-token: |
| 13 | + description: 'void.app deploy token (pass secrets.VOID_TOKEN).' |
| 14 | + required: true |
| 15 | + cache-ref: |
| 16 | + description: >- |
| 17 | + Ref-scoped segment of the Vite Task cache key: main, or pr-<number> for |
| 18 | + PR previews. Non-main refs fall back to the main cache on restore. |
| 19 | + required: false |
| 20 | + default: 'main' |
| 21 | + cache-sha: |
| 22 | + description: 'Commit sha that scopes the primary cache key.' |
| 23 | + required: false |
| 24 | + default: ${{ github.sha }} |
| 25 | + site-origin: |
| 26 | + description: >- |
| 27 | + Origin of this deploy when it is not production viteplus.dev |
| 28 | + (e.g. https://main.viteplus.dev). When set, the docs build rewrites the |
| 29 | + https://vite.plus installer URLs to this origin's install scripts. |
| 30 | + Leave empty for production. |
| 31 | + required: false |
| 32 | + default: '' |
| 33 | + |
| 34 | +runs: |
| 35 | + using: 'composite' |
| 36 | + steps: |
| 37 | + - uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # main |
| 38 | + with: |
| 39 | + cache: true |
| 40 | + working-directory: docs |
| 41 | + cache-dependency-path: docs/pnpm-lock.yaml |
| 42 | + |
| 43 | + - name: Compute Vite Task cache keys |
| 44 | + id: cache-keys |
| 45 | + shell: bash |
| 46 | + env: |
| 47 | + CACHE_REF: ${{ inputs.cache-ref }} |
| 48 | + CACHE_SHA: ${{ inputs.cache-sha }} |
| 49 | + run: | |
| 50 | + prefix="vite-task-docs-${RUNNER_OS}-${RUNNER_ARCH}" |
| 51 | + { |
| 52 | + echo "key=${prefix}-${CACHE_REF}-${CACHE_SHA}" |
| 53 | + echo 'restore-keys<<EOF' |
| 54 | + echo "${prefix}-${CACHE_REF}-" |
| 55 | + if [ "$CACHE_REF" != 'main' ]; then |
| 56 | + echo "${prefix}-main-" |
| 57 | + fi |
| 58 | + echo 'EOF' |
| 59 | + } >> "$GITHUB_OUTPUT" |
| 60 | +
|
| 61 | + - name: Restore docs Vite Task cache |
| 62 | + id: vite-task-cache |
| 63 | + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 64 | + with: |
| 65 | + path: docs/node_modules/.vite/task-cache |
| 66 | + key: ${{ steps.cache-keys.outputs.key }} |
| 67 | + # Prefer this ref's newest cache; Vite Task fingerprints decide reuse. |
| 68 | + restore-keys: ${{ steps.cache-keys.outputs.restore-keys }} |
| 69 | + |
| 70 | + - run: vp run build |
| 71 | + shell: bash |
| 72 | + working-directory: docs |
| 73 | + env: |
| 74 | + DOCS_SITE_ORIGIN: ${{ inputs.site-origin }} |
| 75 | + |
| 76 | + - name: Save docs Vite Task cache |
| 77 | + if: success() && steps.vite-task-cache.outputs.cache-hit != 'true' |
| 78 | + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 79 | + with: |
| 80 | + path: docs/node_modules/.vite/task-cache |
| 81 | + key: ${{ steps.vite-task-cache.outputs.cache-primary-key }} |
| 82 | + |
| 83 | + - run: vpx void deploy --dir docs/.vitepress/dist |
| 84 | + shell: bash |
| 85 | + env: |
| 86 | + VOID_PROJECT: ${{ inputs.void-project }} |
| 87 | + VOID_TOKEN: ${{ inputs.void-token }} |
0 commit comments