-
Notifications
You must be signed in to change notification settings - Fork 22
97 lines (82 loc) · 2.65 KB
/
preview.yaml
File metadata and controls
97 lines (82 loc) · 2.65 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
94
95
96
97
name: Preview on Github Page
on:
push:
branches: [main]
paths:
- "src/**"
- "public/**"
- "index.html"
- "package.json"
- "vite.config.ts"
- ".github/workflows/preview.yaml"
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ steps.check_iteration.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check betaIteration change
id: check_iteration
run: |
# 获取当前 betaIteration 值
CURRENT=$(grep -oP 'betaIteration:\s*\K\d+' src/stores/configStore.ts)
echo "Current betaIteration: $CURRENT"
# 如果 betaIteration 小于等于 0,仅校验不部署
if [ "$CURRENT" -le "0" ]; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "ℹ️ betaIteration is $CURRENT (<=0), will skip deployment (validate only)"
exit 0
fi
# 获取上一次 commit 的 betaIteration 值
git fetch origin gh-pages || echo "No gh-pages branch yet"
PREVIOUS=$(git show HEAD~1:src/stores/configStore.ts 2>/dev/null | grep -oP 'betaIteration:\s*\K\d+' || echo "0")
echo "Previous betaIteration: $PREVIOUS"
# 比较是否有变化
if [ "$CURRENT" != "$PREVIOUS" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "✅ betaIteration changed from $PREVIOUS to $CURRENT, will deploy"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "ℹ️ betaIteration unchanged ($CURRENT), will skip deployment"
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- name: Setup Pages
if: steps.check_iteration.outputs.changed == 'true'
uses: actions/configure-pages@v4
- name: Install dependencies
run: yarn install
- name: Build with Vite
run: yarn build --mode preview
- name: Upload artifact
if: steps.check_iteration.outputs.changed == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
deploy:
if: needs.build.outputs.should_deploy == 'true'
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