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 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);