From d544625ec7c674c0929aec08ad0cf24abd4e3c35 Mon Sep 17 00:00:00 2001 From: Colin Regourd Date: Thu, 16 May 2024 13:54:15 +0200 Subject: [PATCH 1/5] Allow customize branch name --- .changeset/good-mice-brake.md | 5 +++++ action.yml | 3 +++ src/index.ts | 1 + src/run.ts | 8 ++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/good-mice-brake.md diff --git a/.changeset/good-mice-brake.md b/.changeset/good-mice-brake.md new file mode 100644 index 00000000..4f61d203 --- /dev/null +++ b/.changeset/good-mice-brake.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Allow customize branch name diff --git a/action.yml b/action.yml index 5b74beca..e4727e07 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,9 @@ inputs: or app who owns the GITHUB_TOKEN. required: false default: "git-cli" + branchName: + description: Sets the branch name for the pull request. Default to `changeset-release/{{$github.ref_name}}` + required: false branch: description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided required: false diff --git a/src/index.ts b/src/index.ts index 1b0f63ab..2f08dd69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -126,6 +126,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; commitMessage: getOptionalInput("commit"), hasPublishScript, branch: getOptionalInput("branch"), + branchName: getOptionalInput("branchName"), }); core.setOutput("pullRequestNumber", String(pullRequestNumber)); diff --git a/src/run.ts b/src/run.ts index 18ec1da4..17dc0177 100644 --- a/src/run.ts +++ b/src/run.ts @@ -20,7 +20,9 @@ import { const require = createRequire(import.meta.url); -// GitHub Issues/PRs messages have a max size limit on the +// GitHub Issues/PRs messages have a max size limit on th + + // message body payload. // `body is too long (maximum is 65536 characters)`. // To avoid that, we ensure to cap the message to 60k chars. @@ -257,6 +259,7 @@ type VersionOptions = { hasPublishScript?: boolean; prBodyMaxCharacters?: number; branch?: string; + branchName?: string; }; type RunVersionResult = { @@ -273,8 +276,9 @@ export async function runVersion({ hasPublishScript = false, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, branch = github.context.ref.replace("refs/heads/", ""), + branchName }: VersionOptions): Promise { - let versionBranch = `changeset-release/${branch}`; + let versionBranch = branchName ?? `changeset-release/${branch}`; let { preState } = await readChangesetState(cwd); From 066a999be5b54981dfe662288e6c200435afe191 Mon Sep 17 00:00:00 2001 From: Colin Regourd Date: Thu, 16 May 2024 14:21:42 +0200 Subject: [PATCH 2/5] Remove spaces --- src/run.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/run.ts b/src/run.ts index 17dc0177..bd44b16c 100644 --- a/src/run.ts +++ b/src/run.ts @@ -20,9 +20,7 @@ import { const require = createRequire(import.meta.url); -// GitHub Issues/PRs messages have a max size limit on th - - +// GitHub Issues/PRs messages have a max size limit on the // message body payload. // `body is too long (maximum is 65536 characters)`. // To avoid that, we ensure to cap the message to 60k chars. From ce499a01d298ecaf5239635d6d4034527d87ac58 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Wed, 16 Jul 2025 10:38:49 -0400 Subject: [PATCH 3/5] Switch approach to using prBranchSuffix --- action.yml | 4 ++-- src/index.ts | 2 +- src/run.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index e4727e07..c401a379 100644 --- a/action.yml +++ b/action.yml @@ -36,8 +36,8 @@ inputs: or app who owns the GITHUB_TOKEN. required: false default: "git-cli" - branchName: - description: Sets the branch name for the pull request. Default to `changeset-release/{{$github.ref_name}}` + prBranchSuffix: + description: The suffix to include after `changeset-release/` in the PR branch. Defaults to the `branch` variable. required: false branch: description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided diff --git a/src/index.ts b/src/index.ts index 2f08dd69..688c1077 100644 --- a/src/index.ts +++ b/src/index.ts @@ -126,7 +126,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; commitMessage: getOptionalInput("commit"), hasPublishScript, branch: getOptionalInput("branch"), - branchName: getOptionalInput("branchName"), + prBranchSuffix: getOptionalInput("prBranchSuffix"), }); core.setOutput("pullRequestNumber", String(pullRequestNumber)); diff --git a/src/run.ts b/src/run.ts index bd44b16c..f8fb27dd 100644 --- a/src/run.ts +++ b/src/run.ts @@ -257,7 +257,7 @@ type VersionOptions = { hasPublishScript?: boolean; prBodyMaxCharacters?: number; branch?: string; - branchName?: string; + prBranchSuffix?: string; }; type RunVersionResult = { @@ -274,9 +274,9 @@ export async function runVersion({ hasPublishScript = false, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, branch = github.context.ref.replace("refs/heads/", ""), - branchName + prBranchSuffix, }: VersionOptions): Promise { - let versionBranch = branchName ?? `changeset-release/${branch}`; + let versionBranch = `changeset-release/${prBranchSuffix ?? branch}`; let { preState } = await readChangesetState(cwd); From 7253199e1adf96ec36c4c422b2377d65e8cc3cd7 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Wed, 16 Jul 2025 10:42:04 -0400 Subject: [PATCH 4/5] Document the branch and prBranchSuffix inputs --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5ea2e5e5..33c0f934 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ This action for [Changesets](https://github.com/changesets/changesets) creates a - createGithubReleases - A boolean value to indicate whether to create Github releases after `publish` or not. Default to `true` - commitMode - Specifies the commit mode. Use `"git-cli"` to push changes using the Git CLI, or `"github-api"` to push changes via the GitHub API. When using `"github-api"`, all commits and tags are GPG-signed and attributed to the user or app who owns the `GITHUB_TOKEN`. Default to `git-cli`. - cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()` +- branch - Sets the branch in which the action will run. Default to `github.ref_name` +- prBranchSuffix - The suffix to include after `changeset-release/` in the PR branch. Defaults to the `branch` variable. ### Outputs From b7d24f0a6b2ca641b27101079cb48a0e1f9004ed Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Thu, 17 Jul 2025 10:01:58 -0400 Subject: [PATCH 5/5] Update changeset --- .changeset/good-mice-brake.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/good-mice-brake.md b/.changeset/good-mice-brake.md index 4f61d203..5f7b1b61 100644 --- a/.changeset/good-mice-brake.md +++ b/.changeset/good-mice-brake.md @@ -1,5 +1,5 @@ --- -"@changesets/action": patch +"@changesets/action": minor --- -Allow customize branch name +Allow a custom PR branch name with prBranchSuffix