Skip to content

Commit b6f0252

Browse files
committed
chore: fix deploy workflow
1 parent 0c6b1f4 commit b6f0252

File tree

2 files changed

+23
-104
lines changed

2 files changed

+23
-104
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,29 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Setup
25-
uses: ./.github/actions/setup
26-
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: 'yarn'
29+
cache-dependency-path: docs/yarn.lock
30+
31+
- name: Install dependencies
32+
working-directory: docs
33+
run: yarn install --frozen-lockfile
34+
2735
- name: Type check
2836
working-directory: docs
2937
run: yarn typecheck
3038

3139
- name: Build website
3240
working-directory: docs
3341
run: yarn build
34-
env:
35-
NODE_ENV: production
36-
37-
- name: Verify build output
38-
run: |
39-
if [ ! -d "docs/build" ]; then
40-
echo "❌ Build directory not found"
41-
exit 1
42-
fi
43-
echo "✅ Build completed successfully"
44-
ls -la docs/build/
4542

4643
- name: Upload Build Artifact
4744
uses: actions/upload-pages-artifact@v3
4845
with:
4946
path: docs/build
50-
retention-days: 1
5147

5248
deploy:
5349
name: Deploy to GitHub Pages

.github/workflows/test-deploy.yml

Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -21,98 +21,21 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Setup
25-
uses: ./.github/actions/setup
26-
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: 'yarn'
29+
cache-dependency-path: docs/yarn.lock
30+
31+
- name: Install dependencies
32+
working-directory: docs
33+
run: yarn install --frozen-lockfile
34+
2735
- name: Type check
2836
working-directory: docs
2937
run: yarn typecheck
3038

31-
- name: Lint check
32-
working-directory: docs
33-
run: |
34-
if yarn lint 2>/dev/null; then
35-
echo "✅ Lint check passed"
36-
else
37-
echo "⚠️ No lint script found, skipping lint check"
38-
fi
39-
4039
- name: Test build website
4140
working-directory: docs
42-
run: yarn build
43-
env:
44-
NODE_ENV: production
45-
46-
- name: Verify build output
47-
id: verify-build
48-
run: |
49-
if [ ! -d "docs/build" ]; then
50-
echo "❌ Build directory not found"
51-
exit 1
52-
fi
53-
54-
# 检查关键文件是否存在
55-
if [ ! -f "docs/build/index.html" ]; then
56-
echo "❌ index.html not found in build output"
57-
exit 1
58-
fi
59-
60-
echo "✅ Build completed successfully"
61-
echo "📁 Build directory contents:"
62-
ls -la docs/build/
63-
64-
# 检查构建大小
65-
BUILD_SIZE=$(du -sh docs/build | cut -f1)
66-
echo "build-size=$BUILD_SIZE" >> $GITHUB_OUTPUT
67-
echo "📊 Build size: $BUILD_SIZE"
68-
69-
- name: Test serve locally
70-
working-directory: docs
71-
run: |
72-
# 启动本地服务器进行测试
73-
timeout 30s yarn serve --port 3000 &
74-
SERVER_PID=$!
75-
76-
# 等待服务器启动
77-
sleep 10
78-
79-
# 测试服务器是否响应
80-
if curl -f http://localhost:3000 > /dev/null 2>&1; then
81-
echo "✅ Local server test passed"
82-
else
83-
echo "❌ Local server test failed"
84-
exit 1
85-
fi
86-
87-
# 清理进程
88-
kill $SERVER_PID 2>/dev/null || true
89-
90-
- name: Comment on PR
91-
if: github.event_name == 'pull_request'
92-
uses: actions/github-script@v7
93-
with:
94-
script: |
95-
const buildSize = '${{ steps.verify-build.outputs.build-size }}' || 'Unknown';
96-
97-
github.rest.issues.createComment({
98-
issue_number: context.issue.number,
99-
owner: context.repo.owner,
100-
repo: context.repo.repo,
101-
body: `🧪 **Test deployment completed successfully!**
102-
103-
✅ **Type check**: Passed
104-
✅ **Build**: Successful
105-
✅ **Local server test**: Passed
106-
📊 **Build size**: ${buildSize}
107-
108-
The documentation build is ready for deployment. 🚀`
109-
})
110-
111-
- name: Upload build artifacts for inspection
112-
uses: actions/upload-artifact@v4
113-
if: always()
114-
with:
115-
name: test-build-artifacts
116-
path: docs/build/
117-
retention-days: 7
118-
if-no-files-found: error
41+
run: yarn build

0 commit comments

Comments
 (0)