From 02f129e6855b7b0cd754948b960d757b1ffc9cfb Mon Sep 17 00:00:00 2001 From: ernestognw Date: Thu, 19 Jan 2023 11:29:48 -0600 Subject: [PATCH 1/2] Feature: Allow custom `branch` --- action.yml | 3 +++ src/index.ts | 1 + src/run.ts | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 36dfeafb..7443fad2 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 11214453..5d61b76e 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 ab35297b..0617fc24 100644 --- a/src/run.ts +++ b/src/run.ts @@ -251,6 +251,7 @@ type VersionOptions = { commitMessage?: string; hasPublishScript?: boolean; prBodyMaxCharacters?: number; + branch?: string; }; type RunVersionResult = { @@ -265,9 +266,10 @@ export async function runVersion({ commitMessage = "Version Packages", hasPublishScript = false, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, + branch, }: VersionOptions): Promise { 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 octokit = github.getOctokit(githubToken); let { preState } = await readChangesetState(cwd); From a2f0eccff0b31bc0a45b95eb2478e2baf54bf189 Mon Sep 17 00:00:00 2001 From: ernestognw Date: Thu, 19 Jan 2023 11:31:01 -0600 Subject: [PATCH 2/2] Add changeset --- .changeset/happy-singers-hammer.md | 5 +++++ 1 file changed, 5 insertions(+) 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