Skip to content

Commit eeeac95

Browse files
committed
ci: 修改流水线配置,支持手动指定包名触发流水线
1 parent 5e386b2 commit eeeac95

1 file changed

Lines changed: 52 additions & 11 deletions

File tree

.github/workflows/CD.yaml

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,44 @@ on:
1212
push:
1313
branches:
1414
- next
15-
- ci-test
15+
- fix/cd
1616
workflow_dispatch:
17+
inputs:
18+
package:
19+
description: 要发布的 npm 包(手动触发时必选)
20+
required: true
21+
type: choice
22+
options:
23+
- '@142vip/axios'
24+
- '@142vip/changelog'
25+
- '@142vip/commit-linter'
26+
- '@142vip/copyright'
27+
- '@142vip/data-source'
28+
- '@142vip/egg'
29+
- '@142vip/egg-axios'
30+
- '@142vip/egg-grpc-client'
31+
- '@142vip/egg-grpc-server'
32+
- '@142vip/egg-mysql'
33+
- '@142vip/egg-redis'
34+
- '@142vip/egg-sequelize'
35+
- '@142vip/egg-swagger'
36+
- '@142vip/egg-validate'
37+
- '@142vip/eslint-config'
38+
- '@142vip/fairy-cli'
39+
- '@142vip/grpc'
40+
- '@142vip/nest'
41+
- '@142vip/nest-logger'
42+
- '@142vip/nest-redis'
43+
- '@142vip/nest-starter'
44+
- '@142vip/nest-typeorm'
45+
- '@142vip/oauth2.0'
46+
- '@142vip/open-source'
47+
- '@142vip/redis'
48+
- '@142vip/release-version'
49+
- '@142vip/typeorm'
50+
- '@142vip/utils'
51+
- '@142vip/vitepress'
52+
- '@142vip/vuepress'
1753

1854
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
1955
permissions:
@@ -27,7 +63,7 @@ jobs:
2763
name: 创建Github发布
2864
runs-on: ubuntu-latest
2965
# 主库next且执行release更新时执行
30-
if: github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
66+
if: github.event_name == 'push' && github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
3167

3268
steps:
3369
- name: Checkout Code
@@ -69,8 +105,10 @@ jobs:
69105
npm-release:
70106
name: 创建npm发布
71107
runs-on: ubuntu-latest
72-
# 主库next且执行release更新时执行
73-
if: github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'release(@142vip/')
108+
# push: release(@scope/pkg) 提交;workflow_dispatch: 手动选择包发版
109+
if: |
110+
(github.event_name == 'workflow_dispatch' && github.event.inputs.package != '') ||
111+
(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'release(@'))
74112
75113
steps:
76114
- name: Checkout Code
@@ -105,12 +143,15 @@ jobs:
105143
# run: |
106144
# pnpm build:packages
107145

108-
- name: Get Package Name By Commit Scope
146+
- name: Resolve Package Name
109147
id: getPkgName
110-
# 这里使用正则截取scope,获取包名
111148
run: |
112-
SCOPE=$(echo "${{ github.event.head_commit.message }}" | grep -o '@[^):]*')
113-
echo "name=$SCOPE" >> $GITHUB_OUTPUT
149+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
150+
echo "name=${{ github.event.inputs.package }}" >> "$GITHUB_OUTPUT"
151+
else
152+
SCOPE=$(echo "${{ github.event.head_commit.message }}" | grep -o '@[^):]*' | head -1)
153+
echo "name=${SCOPE}" >> "$GITHUB_OUTPUT"
154+
fi
114155
115156
- name: Use Package Name
116157
run: |
@@ -130,8 +171,8 @@ jobs:
130171
environment:
131172
name: github-pages
132173
url: ${{ steps.deployment.outputs.page_url }}
133-
# todo 确定这里的触发条件
134-
if: github.repository == '142vip/core-x'
174+
# 仅 push 到 next/fix/cd 时部署文档,手动发版 npm 不触发
175+
if: github.event_name == 'push' && github.repository == '142vip/core-x'
135176
steps:
136177
# 拉取代码
137178
- name: Checkout
@@ -190,7 +231,7 @@ jobs:
190231
name: 部署到Github Wiki
191232
runs-on: ubuntu-latest
192233
# 主库next且执行release更新时执行
193-
if: github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
234+
if: github.event_name == 'push' && github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
194235
steps:
195236
- name: Checkout Code
196237
uses: actions/checkout@v4

0 commit comments

Comments
 (0)