Skip to content

Commit dce61f1

Browse files
committed
ci: 移除对可复用工作流的依赖
1 parent 86b6ab5 commit dce61f1

2 files changed

Lines changed: 147 additions & 14 deletions

File tree

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# 文件名建议统一为 preview-publish
2-
# 应用 preview.yml 的 demo
31
name: PREVIEW_PUBLISH
42

53
on:
@@ -9,7 +7,86 @@ on:
97
- completed
108

119
jobs:
12-
call-preview:
13-
uses: TDesignOteam/workflows/.github/workflows/reusable-pr-preview.yml@main
14-
secrets:
15-
TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }}
10+
preview-deploy:
11+
runs-on: ubuntu-latest
12+
if: >
13+
github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion == 'success'
15+
steps:
16+
- name: Download pr artifact
17+
uses: dawidd6/action-download-artifact@v8
18+
with:
19+
workflow: ${{ github.event.workflow_run.workflow_id }}
20+
run_id: ${{ github.event.workflow_run.id }}
21+
name: pr
22+
23+
- name: Save PR id
24+
id: pr
25+
run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
26+
27+
- name: Download site artifact
28+
uses: dawidd6/action-download-artifact@v8
29+
with:
30+
workflow: ${{ github.event.workflow_run.workflow_id }}
31+
run_id: ${{ github.event.workflow_run.id }}
32+
name: _site
33+
34+
- run: unzip _site.zip
35+
36+
- name: Deploy to Surge
37+
id: deploy
38+
run: |
39+
export DEPLOY_DOMAIN=https://preview-pr-${{ steps.pr.outputs.id }}-tdesign-starter-cli.surge.sh
40+
npx surge --project ./_site --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }}
41+
echo "url=$DEPLOY_DOMAIN" >> $GITHUB_OUTPUT
42+
43+
- name: Comment preview URL
44+
uses: actions-cool/maintain-one-comment@v3
45+
with:
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
body: |
48+
<a href="${{ steps.deploy.outputs.url }}"><img height="96" alt="完成" src="https://user-images.githubusercontent.com/15634204/150816437-9f5bb788-cd67-4cbc-9897-b82d74e9aa65.png" /></a>
49+
<!-- AUTO_PREVIEW_HOOK -->
50+
number: ${{ steps.pr.outputs.id }}
51+
body-include: <!-- AUTO_PREVIEW_HOOK -->
52+
53+
- name: Clean up
54+
run: rm -rf _site/
55+
56+
- name: Deploy failed
57+
if: failure()
58+
uses: actions-cool/maintain-one-comment@v3
59+
with:
60+
token: ${{ secrets.GITHUB_TOKEN }}
61+
body: |
62+
[<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 }})
63+
<!-- AUTO_PREVIEW_HOOK -->
64+
number: ${{ steps.pr.outputs.id }}
65+
body-include: <!-- AUTO_PREVIEW_HOOK -->
66+
67+
preview-failed:
68+
runs-on: ubuntu-latest
69+
if: >
70+
github.event.workflow_run.event == 'pull_request' &&
71+
github.event.workflow_run.conclusion == 'failure'
72+
steps:
73+
- name: Download pr artifact
74+
uses: dawidd6/action-download-artifact@v8
75+
with:
76+
workflow: ${{ github.event.workflow_run.workflow_id }}
77+
run_id: ${{ github.event.workflow_run.id }}
78+
name: pr
79+
80+
- name: Save PR id
81+
id: pr
82+
run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
83+
84+
- name: Comment failure
85+
uses: actions-cool/maintain-one-comment@v3
86+
with:
87+
token: ${{ secrets.GITHUB_TOKEN }}
88+
body: |
89+
[<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 }})
90+
<!-- AUTO_PREVIEW_HOOK -->
91+
number: ${{ steps.pr.outputs.id }}
92+
body-include: <!-- AUTO_PREVIEW_HOOK -->

.github/workflows/pull-request.yml

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# 文件名建议统一为 pull-request.yml
2-
# 应用 test-build.yml 的 demo
3-
41
name: MAIN_PULL_REQUEST
52

63
on:
@@ -9,8 +6,67 @@ on:
96
types: [opened, synchronize, reopened]
107

118
jobs:
12-
call-test-build:
13-
uses: TDesignOteam/workflows/.github/workflows/reusable-unit-test.yml@main
14-
with:
15-
package-manager: pnpm
16-
node-version-file: .node-version
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: pnpm/action-setup@v4
15+
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version-file: .node-version
19+
cache: pnpm
20+
21+
- run: pnpm install --frozen-lockfile
22+
23+
- run: pnpm run lint
24+
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: pnpm/action-setup@v4
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version-file: .node-version
35+
cache: pnpm
36+
37+
- run: pnpm install --frozen-lockfile
38+
39+
- run: pnpm run build
40+
41+
site-preview:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- run: echo ${{ github.event.number }} > pr-id.txt
45+
46+
- uses: actions/upload-artifact@v4
47+
with:
48+
name: pr
49+
path: pr-id.txt
50+
retention-days: 5
51+
52+
- uses: actions/checkout@v4
53+
54+
- uses: pnpm/action-setup@v4
55+
56+
- uses: actions/setup-node@v4
57+
with:
58+
node-version-file: .node-version
59+
cache: pnpm
60+
61+
- run: pnpm install --frozen-lockfile
62+
63+
- run: pnpm run site:preview
64+
65+
- name: Zip site
66+
run: cd _site && zip -r ../_site.zip . && cd ..
67+
68+
- uses: actions/upload-artifact@v4
69+
with:
70+
name: _site
71+
path: _site.zip
72+
retention-days: 5

0 commit comments

Comments
 (0)