-
Notifications
You must be signed in to change notification settings - Fork 223
93 lines (82 loc) · 3.26 KB
/
Copy pathdeploy-docs-preview.yml
File metadata and controls
93 lines (82 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Deploy Docs Preview
permissions: {}
on:
pull_request:
paths:
- 'docs/**'
- 'packages/cli/install.sh'
- 'packages/cli/install.ps1'
- '.github/workflows/deploy-docs-preview.yml'
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
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
- uses: voidzero-dev/setup-vp@13e7afb99c66525824db54e107d667216e795d37 # main
with:
cache: true
working-directory: docs
cache-dependency-path: docs/pnpm-lock.yaml
- name: Restore docs Vite Task cache
id: vite-task-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: docs/node_modules/.vite/task-cache
key: vite-task-docs-${{ runner.os }}-${{ runner.arch }}-pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
# Prefer this PR's newest cache, then fall back to main for new PRs.
restore-keys: |
vite-task-docs-${{ runner.os }}-${{ runner.arch }}-pr-${{ github.event.pull_request.number }}-
vite-task-docs-${{ runner.os }}-${{ runner.arch }}-main-
- run: vp run build
working-directory: docs
- name: Save docs Vite Task cache
if: success() && steps.vite-task-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: docs/node_modules/.vite/task-cache
key: ${{ steps.vite-task-cache.outputs.cache-primary-key }}
- run: vpx void deploy --dir docs/.vitepress/dist
env:
VOID_TOKEN: ${{ secrets.VOID_TOKEN }}
- name: Comment on PR
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
env:
PREVIEW_URL: ${{ env.PREVIEW_URL }}
with:
script: |
const marker = '<!-- staging-deploy -->';
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,
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,
});
}