Skip to content

Commit a858e75

Browse files
committed
feat: add PR preview workflow
1 parent 4beca85 commit a858e75

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/pr-preview.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Deploy PR preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, closed]
6+
7+
concurrency: preview-${{ github.ref }}
8+
9+
jobs:
10+
deploy-preview:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install and build
23+
if: github.event.action != 'closed'
24+
run: |
25+
npm install
26+
npm run build
27+
28+
- name: Deploy preview
29+
uses: rossjrw/pr-preview-action@v1
30+
with:
31+
source-dir: ./dist
32+
preview-branch: gh-pages
33+
umbrella-dir: pr-preview

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
2. 在仓库设置中启用 GitHub Pages
7878
3. 选择 GitHub Actions 作为部署源
7979
4. 推送代码时将自动触发构建和部署
80+
5. 每个 PR 会自动生成预览链接,合并前即可在线查看效果
8081

8182
## 📝 使用指南
8283

0 commit comments

Comments
 (0)