From f2660aa7e78365f53dbeb4cfa774c1499ec6483a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Garc=C3=ADa?= Date: Mon, 18 Mar 2024 22:57:05 +0000 Subject: [PATCH] Feature: Allow custom `branch` (#255) --- .changeset/happy-singers-hammer.md | 5 +++++ action.yml | 3 +++ src/index.ts | 1 + src/run.ts | 4 +++- 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/happy-singers-hammer.md diff --git a/.changeset/happy-singers-hammer.md b/.changeset/happy-singers-hammer.md new file mode 100644 index 00000000..0555e7a4 --- /dev/null +++ b/.changeset/happy-singers-hammer.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Allow customize PR `branch` field diff --git a/action.yml b/action.yml index 71a90d57..86b97909 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,9 @@ inputs: description: "A boolean value to indicate whether to create Github releases after `publish` or not" required: false default: true + branch: + description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided + required: false outputs: published: description: A boolean value to indicate whether a publishing is happened or not diff --git a/src/index.ts b/src/index.ts index 51ca39e2..31aef207 100644 --- a/src/index.ts +++ b/src/index.ts @@ -109,6 +109,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; prTitle: getOptionalInput("title"), commitMessage: getOptionalInput("commit"), hasPublishScript, + branch: getOptionalInput("branch"), }); core.setOutput("pullRequestNumber", String(pullRequestNumber)); diff --git a/src/run.ts b/src/run.ts index 67d70f09..ea346bf6 100644 --- a/src/run.ts +++ b/src/run.ts @@ -299,6 +299,7 @@ type VersionOptions = { commitMessage?: string; hasPublishScript?: boolean; prBodyMaxCharacters?: number; + branch?: string; }; type RunVersionResult = { @@ -313,11 +314,12 @@ export async function runVersion({ commitMessage = "Version Packages", hasPublishScript = false, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, + branch, }: VersionOptions): Promise { const octokit = setupOctokit(githubToken); let repo = `${github.context.repo.owner}/${github.context.repo.repo}`; - let branch = github.context.ref.replace("refs/heads/", ""); + branch = branch ?? github.context.ref.replace("refs/heads/", ""); let versionBranch = `changeset-release/${branch}`; let { preState } = await readChangesetState(cwd);