Skip to content

Commit c3c2330

Browse files
committed
modify deploy github action rule
1 parent 2408658 commit c3c2330

4 files changed

Lines changed: 52 additions & 59 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,68 @@
11
name: Test on Release
22

33
on:
4-
release:
5-
types: [published]
64
push:
5+
branches:
6+
- main
7+
- develop
78
tags:
8-
- 'v*'
9+
- 'v[0-9]+.[0-9]+.[0-9]+'
10+
pull_request:
11+
branches:
12+
- main
13+
- develop
914

1015
jobs:
1116
test:
17+
if: github.event_name == 'push' || github.event_name == 'pull_request'
1218
runs-on: ubuntu-latest
13-
19+
1420
steps:
1521
- uses: actions/checkout@v3
16-
22+
1723
- name: Setup Node.js
1824
uses: actions/setup-node@v3
1925
with:
20-
node-version: '18'
26+
node-version: '20'
2127
cache: 'yarn'
22-
28+
2329
- name: Install dependencies
2430
run: yarn install --frozen-lockfile
25-
31+
2632
- name: Run tests
27-
run: yarn test
33+
run: yarn test
34+
35+
deploy:
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-table": "link:.."#"@acrool/react-table": "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 }}

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"storybook": "storybook dev -p 6006",
88
"build-storybook": "storybook build",
99
"pages:dev": "wrangler pages dev --proxy 3000 -- yarn dev",
10-
"pages:deploy": "NODE_VERSION=18 yarn build-storybook && wrangler pages deploy ./storybook-static --project-name=acrool-react-table-storybook --branch main"
10+
"pages:deploy": "NODE_VERSION=20 yarn build-storybook && wrangler pages deploy ./storybook-static --project-name=acrool-react-table-storybook --branch main"
1111
},
1212
"resolutions": {
1313
"styled-components": "6.1.17"

jest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
coverageDirectory: 'coverage',
33
preset: 'ts-jest',
44
testEnvironment: 'jsdom',
5-
testMatch: ['<rootDir>/**/*.test.ts?(x)'],
5+
testMatch: ['<rootDir>/**/*.(spec|test).ts?(x)'],
66
transform: {
77
'^.+\\.(t|j)sx?$': [
88
'@swc/jest',

0 commit comments

Comments
 (0)