Skip to content

Commit 6027b91

Browse files
committed
modify deploy github action rule
1 parent d82c99d commit 6027b91

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

.github/workflows/test-on-release.yml

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ name: Test on Release
33
on:
44
push:
55
branches:
6-
- '**'
6+
- main
7+
- develop
78
tags:
89
- 'v[0-9]+.[0-9]+.[0-9]+'
10+
pull_request:
11+
branches:
12+
- main
13+
- develop
914

1015
jobs:
1116
test:
12-
if: github.ref_type == 'branch'
17+
if: github.event_name == 'push' || github.event_name == 'pull_request'
1318
runs-on: ubuntu-latest
1419

1520
steps:
@@ -28,35 +33,36 @@ jobs:
2833
run: yarn test
2934

3035
deploy:
31-
if: startsWith(github.ref, 'refs/tags/v')
32-
runs-on: ubuntu-latest
33-
34-
defaults:
35-
run:
36-
working-directory: ./example
37-
38-
steps:
39-
- name: Checkout repository
40-
uses: actions/checkout@v3
41-
42-
- name: Wait for npm publish
43-
run: sleep 30 # 延遲30秒,可根據實際情況調整
44-
45-
- name: Set up Node.js
46-
uses: actions/setup-node@v3
47-
with:
48-
node-version: '20'
49-
50-
- name: Replace local links with actual versions
51-
run: |
52-
sed -i 's#"@acrool/react-toaster": "link:.."#"@acrool/react-toaster": "latest"#' package.json
53-
sed -i 's#"react": "link:../node_modules/react"#"react": "^19.1.0"#' package.json
54-
sed -i 's#"react-dom": "link:../node_modules/react-dom"#"react-dom": "^19.1.0"#' package.json
55-
56-
- name: Install dependencies
57-
run: yarn install
58-
59-
- name: Build Storybook & Deploy to Cloudflare Pages
60-
run: yarn pages:deploy
61-
env:
62-
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
36+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
37+
needs: test
38+
runs-on: ubuntu-latest
39+
40+
defaults:
41+
run:
42+
working-directory: ./example
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v3
47+
48+
- name: Wait for npm publish
49+
run: sleep 30 # 延遲30秒,可根據實際情況調整
50+
51+
- name: Set up Node.js
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: '20'
55+
56+
- name: Replace local links with actual versions
57+
run: |
58+
sed -i 's#"@acrool/react-toaster": "link:.."#"@acrool/react-toaster": "latest"#' package.json
59+
sed -i 's#"react": "link:../node_modules/react"#"react": "^19.1.0"#' package.json
60+
sed -i 's#"react-dom": "link:../node_modules/react-dom"#"react-dom": "^19.1.0"#' package.json
61+
62+
- name: Install dependencies
63+
run: yarn install
64+
65+
- name: Build Storybook & Deploy to Cloudflare Pages
66+
run: yarn pages:deploy
67+
env:
68+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

0 commit comments

Comments
 (0)