From b14e338d2e84cb4a5ecd385dd219e91c6a3c34dd Mon Sep 17 00:00:00 2001 From: MK Date: Fri, 15 May 2026 21:50:35 +0800 Subject: [PATCH 1/2] ci(docs): add Void deploy workflows for docs site Add two GitHub workflows that deploy the VitePress docs site to void.cloud, mirroring the pattern used in voidzero-dev/setup.viteplus.dev: - deploy-docs.yml: push to main (or workflow_dispatch) deploys to the `viteplus` production project. - deploy-docs-preview.yml: pull_request deploys to the `viteplus-staging` project and posts a sticky preview-URL comment on the PR. Both build the docs via `vp run build` inside docs/ and upload the pre-built static directory with `vpx void deploy --dir docs/.vitepress/dist`. Triggered only when docs/**, packages/cli/install.sh, packages/cli/install.ps1, or the workflow file itself changes. Also ignore the local `.void/` directory created by `void deploy` (holds `project.json` linking the working tree to a void project). Requires the `VOID_TOKEN` repo secret and the two void projects (`viteplus`, `viteplus-staging`) to be provisioned before workflows can succeed. --- .github/workflows/deploy-docs-preview.yml | 69 +++++++++++++++++++++++ .github/workflows/deploy-docs.yml | 42 ++++++++++++++ .gitignore | 1 + 3 files changed, 112 insertions(+) create mode 100644 .github/workflows/deploy-docs-preview.yml create mode 100644 .github/workflows/deploy-docs.yml diff --git a/.github/workflows/deploy-docs-preview.yml b/.github/workflows/deploy-docs-preview.yml new file mode 100644 index 0000000000..08e0e08ad5 --- /dev/null +++ b/.github/workflows/deploy-docs-preview.yml @@ -0,0 +1,69 @@ +name: Deploy Docs Preview + +on: + pull_request: + paths: + - 'docs/**' + - 'packages/cli/install.sh' + - 'packages/cli/install.ps1' + - '.github/workflows/deploy-docs-preview.yml' + +permissions: + contents: read + pull-requests: write + +concurrency: + group: deploy-docs-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + staging-deploy: + if: github.repository == 'voidzero-dev/vite-plus' + runs-on: ubuntu-latest + steps: + - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 + + - uses: voidzero-dev/setup-vp@ca1c46663915d6c1042ae23bd39ab85718bfb0fa # v1.10.0 + with: + cache: true + working-directory: docs + + - run: vp run build + working-directory: docs + + - run: vpx void deploy --dir docs/.vitepress/dist + env: + VOID_TOKEN: ${{ secrets.VOID_TOKEN }} + VOID_PROJECT: viteplus-staging + + - name: Comment on PR + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 + with: + script: | + const marker = ''; + const body = `${marker}\nāœ… Staging deployment successful!\n\nPreview: https://viteplus-staging.void.app/\nCommit: ${context.sha}`; + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + const existing = comments.find(c => c.body.includes(marker)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000000..2089bbdb3e --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,42 @@ +name: Deploy Docs + +on: + push: + branches: [main] + paths: + - 'docs/**' + - 'packages/cli/install.sh' + - 'packages/cli/install.ps1' + - '.github/workflows/deploy-docs.yml' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: deploy-docs-${{ github.ref }} + cancel-in-progress: false + +defaults: + run: + shell: bash + +jobs: + deploy: + if: github.repository == 'voidzero-dev/vite-plus' + runs-on: ubuntu-latest + steps: + - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 + + - uses: voidzero-dev/setup-vp@ca1c46663915d6c1042ae23bd39ab85718bfb0fa # v1.10.0 + with: + cache: true + working-directory: docs + + - run: vp run build + working-directory: docs + + - run: vpx void deploy --dir docs/.vitepress/dist + env: + VOID_TOKEN: ${{ secrets.VOID_TOKEN }} + VOID_PROJECT: viteplus diff --git a/.gitignore b/.gitignore index 7821398421..1defa1dc72 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ rolldown rolldown-vite vite /crates/vite_global_cli/vp +.void/ From 4d35424a4bd1decb3a53b521f94cd60507057821 Mon Sep 17 00:00:00 2001 From: MK Date: Fri, 15 May 2026 22:15:21 +0800 Subject: [PATCH 2/2] ci(docs): tighten permissions, dedupe env vars, fix PR head SHA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address simplify review + Cursor Bugbot: - Move workflow-level `permissions:` to `permissions: {}` at top and grant per-job, matching the repo convention used by every other workflow. - Hoist `VOID_PROJECT` (and `PREVIEW_URL` in preview) to job-level `env` so a project rename doesn't leave the URL behind. - Add explicit `cache-dependency-path: docs/pnpm-lock.yaml` to setup-vp for unambiguous cache keying. - Drop `${{ github.ref }}` from the prod concurrency group so a `workflow_dispatch` from a non-main ref can't race a `push` deploy. - Use `context.payload.pull_request.head.sha` instead of `context.sha` in the preview comment — on `pull_request` events `context.sha` is the ephemeral merge commit, not findable in the contributor's branch. --- .github/workflows/deploy-docs-preview.yml | 18 ++++++++++++------ .github/workflows/deploy-docs.yml | 13 ++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-docs-preview.yml b/.github/workflows/deploy-docs-preview.yml index 08e0e08ad5..0036f5681a 100644 --- a/.github/workflows/deploy-docs-preview.yml +++ b/.github/workflows/deploy-docs-preview.yml @@ -1,5 +1,7 @@ name: Deploy Docs Preview +permissions: {} + on: pull_request: paths: @@ -8,10 +10,6 @@ on: - 'packages/cli/install.ps1' - '.github/workflows/deploy-docs-preview.yml' -permissions: - contents: read - pull-requests: write - concurrency: group: deploy-docs-preview-${{ github.event.pull_request.number }} cancel-in-progress: true @@ -24,6 +22,12 @@ jobs: staging-deploy: if: github.repository == 'voidzero-dev/vite-plus' runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + env: + VOID_PROJECT: viteplus-staging + PREVIEW_URL: https://viteplus-staging.void.app/ steps: - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 @@ -31,6 +35,7 @@ jobs: with: cache: true working-directory: docs + cache-dependency-path: docs/pnpm-lock.yaml - run: vp run build working-directory: docs @@ -38,14 +43,15 @@ jobs: - run: vpx void deploy --dir docs/.vitepress/dist env: VOID_TOKEN: ${{ secrets.VOID_TOKEN }} - VOID_PROJECT: viteplus-staging - name: Comment on PR uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 + env: + PREVIEW_URL: ${{ env.PREVIEW_URL }} with: script: | const marker = ''; - const body = `${marker}\nāœ… Staging deployment successful!\n\nPreview: https://viteplus-staging.void.app/\nCommit: ${context.sha}`; + const body = `${marker}\nāœ… Staging deployment successful!\n\nPreview: ${process.env.PREVIEW_URL}\nCommit: ${context.payload.pull_request.head.sha}`; const comments = await github.paginate(github.rest.issues.listComments, { owner: context.repo.owner, repo: context.repo.repo, diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 2089bbdb3e..e6e4dee3d2 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,5 +1,7 @@ name: Deploy Docs +permissions: {} + on: push: branches: [main] @@ -10,11 +12,8 @@ on: - '.github/workflows/deploy-docs.yml' workflow_dispatch: -permissions: - contents: read - concurrency: - group: deploy-docs-${{ github.ref }} + group: deploy-docs cancel-in-progress: false defaults: @@ -25,6 +24,10 @@ jobs: deploy: if: github.repository == 'voidzero-dev/vite-plus' runs-on: ubuntu-latest + permissions: + contents: read + env: + VOID_PROJECT: viteplus steps: - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 @@ -32,6 +35,7 @@ jobs: with: cache: true working-directory: docs + cache-dependency-path: docs/pnpm-lock.yaml - run: vp run build working-directory: docs @@ -39,4 +43,3 @@ jobs: - run: vpx void deploy --dir docs/.vitepress/dist env: VOID_TOKEN: ${{ secrets.VOID_TOKEN }} - VOID_PROJECT: viteplus