Skip to content

Commit c6ac2c0

Browse files
committed
ci: 优化预览发布与PR工作流
1 parent 5db336b commit c6ac2c0

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

.github/workflows/preview-publish.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
types:
77
- completed
88

9+
env:
10+
FAILURE_BODY: |
11+
[<img height="96" alt="失败" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
12+
<!-- AUTO_PREVIEW_HOOK -->
13+
914
jobs:
1015
preview-success-web:
1116
runs-on: ubuntu-latest
@@ -35,9 +40,7 @@ jobs:
3540
- name: Deploy to surge
3641
id: deploy
3742
run: |
38-
repository=${{ github.repository }}
39-
project_name=${repository#*/}
40-
DEPLOY_DOMAIN=https://preview-pr-${{ steps.pr.outputs.number }}-$project_name.surge.sh
43+
DEPLOY_DOMAIN=https://preview-pr-${{ steps.pr.outputs.number }}-${{ github.event.repository.name }}.surge.sh
4144
npx surge --project ./tdesign-flutter-web --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }}
4245
echo "url=$DEPLOY_DOMAIN" >> $GITHUB_OUTPUT
4346
@@ -62,9 +65,7 @@ jobs:
6265
uses: actions-cool/maintain-one-comment@v3
6366
with:
6467
token: ${{ secrets.GITHUB_TOKEN }}
65-
body: |
66-
[<img height="96" alt="失败" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
67-
<!-- AUTO_PREVIEW_HOOK -->
68+
body: ${{ env.FAILURE_BODY }}
6869
number: ${{ steps.pr.outputs.number }}
6970
body-include: "<!-- AUTO_PREVIEW_HOOK -->"
7071

@@ -89,8 +90,6 @@ jobs:
8990
uses: actions-cool/maintain-one-comment@v3
9091
with:
9192
token: ${{ secrets.GITHUB_TOKEN }}
92-
body: |
93-
[<img height="96" alt="失败" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
94-
<!-- AUTO_PREVIEW_HOOK -->
93+
body: ${{ env.FAILURE_BODY }}
9594
number: ${{ steps.pr.outputs.number }}
9695
body-include: "<!-- AUTO_PREVIEW_HOOK -->"

.github/workflows/pull-request.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ jobs:
6565
run: |
6666
# widget_test.dart 会遍历每个组件页面,生成 tdesign-site/src/<组件>/README.md
6767
# (内容已嵌入 example/assets/api/<组件>_api.md 的 API 表格)
68-
flutter test test/widget_test.dart --reporter expanded || \
69-
echo "⚠ Widget test completed with warnings (expected)"
68+
flutter test test/widget_test.dart --reporter expanded
7069
7170
- name: Build site
7271
working-directory: tdesign-flutter/tdesign-site
@@ -81,16 +80,17 @@ jobs:
8180
- name: Assemble preview artifact
8281
run: |
8382
mkdir -p tdesign-flutter-web/flutter/example
84-
# 站点页面(含组件文档,编译产物根目录指向 surge 根)
83+
# 站点页面(编译后的 _site 直接铺到 surge 根)
8584
cp -r tdesign-flutter/tdesign-site/_site/. tdesign-flutter-web/
86-
# surge SPA 兜底
87-
cp tdesign-flutter/tdesign-site/_site/index.html tdesign-flutter-web/404.html
85+
# surge 通过 200.html / 404.html 实现 SPA fallback
8886
cp tdesign-flutter/tdesign-site/_site/index.html tdesign-flutter-web/200.html
89-
# flutter web demo
87+
cp tdesign-flutter/tdesign-site/_site/index.html tdesign-flutter-web/404.html
88+
# flutter web demo(base-href: /flutter/example/)
9089
cp -r tdesign-flutter/tdesign-component/example/build/web/. tdesign-flutter-web/flutter/example/
9190
92-
- uses: actions/upload-artifact@v4
91+
- name: Upload preview artifact
92+
uses: actions/upload-artifact@v4
9393
with:
9494
name: tdesign-flutter-web
95-
path: ${{ github.workspace }}/tdesign-flutter-web
95+
path: tdesign-flutter-web
9696
retention-days: 5

0 commit comments

Comments
 (0)