Skip to content

Commit 5ccecc9

Browse files
authored
Update npm-publish.yml
1 parent 87aa6e7 commit 5ccecc9

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

.github/workflows/npm-publish.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
name: npm publish # 定义工作流名称
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Node.js CI
25

36
on:
4-
workflow_dispatch: # 允许手动触发工作流,默认是不开启的
5-
push: # 当有代码推送到仓库时触发
6-
branches:
7-
- main
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
811

912
jobs:
10-
build: # 工作流程中的一个作业
11-
runs-on: ubuntu-latest # 指定运行作业的虚拟环境
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [22.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
1222
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v4
15-
- name: Set up Node.js
23+
- uses: actions/checkout@v4
24+
- name: Use Node.js ${{ matrix.node-version }}
1625
uses: actions/setup-node@v4
1726
with:
18-
node-version: 20
19-
registry-url: https://registry.npmjs.org/
20-
- name: enable pnpm
21-
run: corepack enable
22-
- name: install Dependencies
23-
run: |
24-
ls -al
25-
pnpm i
26-
pnpm build
27-
- name: Publish to NPM
28-
run: npm publish
27+
node-version: ${{ matrix.node-version }}
28+
# cache: 'pnpm'
29+
# - run: corepack enable # 启用 Corepack(用于管理 pnpm 版本)
30+
# - run: pnpm install --frozen-lockfile # 确保依赖版本与 pnpm-lock.yaml 完全一致
31+
# - run: pnpm run -if-present build # 如果脚本没有定义,不会跑出异常
32+
- run: |
33+
corepack enable
34+
pnpm install --frozen-lockfile
35+
pnpm run -if-present build
36+
- name: Deploy to Vercel
37+
run: npx vercel --token ${VERCEL_TOKEN} --prod
2938
env:
30-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
40+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
41+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}

0 commit comments

Comments
 (0)