Skip to content

Commit a7e317f

Browse files
committed
feat(upgrade-deps): 添加自定义 PR 标题功能
允许在升级依赖时指定自定义的 PR 标题,当未指定时仍使用默认标题格式
1 parent 2b9bbb6 commit a7e317f

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/test-upgrade-deps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
repo: tdesign-vue-next
4343
owner: Tencent
4444
package-manager: pnpm
45+
title: 'chore(deps): Upgrade site-components and theme-generator'
4546
deps: |
4647
@tdesign/site-components
4748
@tdesign/theme-generator

actions/upgrade-deps/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ inputs:
2626
description: Target directory to upgrade dependencies
2727
required: false
2828
default: ''
29+
title:
30+
description: Custom PR title (optional, defaults to "chore: upgrade ...")
31+
required: false
32+
default: ''
33+
2934

3035
runs:
3136
using: node24

packages/upgrade-deps/dist/index.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30230,12 +30230,14 @@ async function createDepsPr(title, branchName, baseBranch, context) {
3023030230
async function updateDependencies(context) {
3023130231
const packageManager = getInput("package-manager") || "npm";
3023230232
const targetDir = getInput("target-dir") || "";
30233+
const customTitle = getInput("title") || "";
3023330234
const deps = getMultilineInput("deps", {
3023430235
required: true,
3023530236
trimWhitespace: true
3023630237
});
3023730238
info(`deps: ${JSON.stringify(deps)}`);
3023830239
info(`target-dir: ${targetDir || "default (repo root)"}`);
30240+
if (customTitle) info(`custom-title: ${customTitle}`);
3023930241
if (!deps.length) throw new ActionError(ERROR_MESSAGES.MISSING_DEPS, { trigger: context.trigger });
3024030242
const depInfos = await getPkgLatestVersion(deps);
3024130243
info(`depInfos: ${JSON.stringify(depInfos)}`);
@@ -30256,7 +30258,10 @@ async function updateDependencies(context) {
3025630258
info("No changes to commit");
3025730259
return;
3025830260
}
30259-
const title = getPrTitle(depInfos);
30261+
startGroup("Changes to commit");
30262+
await gitHelper.printDiff();
30263+
endGroup();
30264+
const title = customTitle || getPrTitle(depInfos);
3026030265
await gitHelper.commit(title);
3026130266
await gitHelper.push(branchName);
3026230267
await createDepsPr(title, branchName, baseBranch, context);

packages/upgrade-deps/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,13 @@ async function createDepsPr(
174174
export async function updateDependencies(context: TriggerContext): Promise<void> {
175175
const packageManager = core.getInput('package-manager') || 'npm'
176176
const targetDir = core.getInput('target-dir') || ''
177+
const customTitle = core.getInput('title') || ''
177178
const deps = core.getMultilineInput('deps', { required: true, trimWhitespace: true })
178179
core.info(`deps: ${JSON.stringify(deps)}`)
179180
core.info(`target-dir: ${targetDir || 'default (repo root)'}`)
181+
if (customTitle) {
182+
core.info(`custom-title: ${customTitle}`)
183+
}
180184

181185
if (!deps.length) {
182186
throw new ActionError(ERROR_MESSAGES.MISSING_DEPS, { trigger: context.trigger })
@@ -212,7 +216,11 @@ export async function updateDependencies(context: TriggerContext): Promise<void>
212216
return
213217
}
214218

215-
const title = getPrTitle(depInfos)
219+
core.startGroup('Changes to commit')
220+
await gitHelper.printDiff()
221+
core.endGroup()
222+
223+
const title = customTitle || getPrTitle(depInfos)
216224
await gitHelper.commit(title)
217225
await gitHelper.push(branchName)
218226

0 commit comments

Comments
 (0)