Feature: Allow custom branch (#255)

This commit is contained in:
Ernesto García
2024-03-19 08:57:05 +10:00
committed by GitHub
parent e245972e63
commit f2660aa7e7
4 changed files with 12 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@changesets/action": patch
---
Allow customize PR `branch` field
+3
View File
@@ -28,6 +28,9 @@ inputs:
description: "A boolean value to indicate whether to create Github releases after `publish` or not" description: "A boolean value to indicate whether to create Github releases after `publish` or not"
required: false required: false
default: true default: true
branch:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
required: false
outputs: outputs:
published: published:
description: A boolean value to indicate whether a publishing is happened or not description: A boolean value to indicate whether a publishing is happened or not
+1
View File
@@ -109,6 +109,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
prTitle: getOptionalInput("title"), prTitle: getOptionalInput("title"),
commitMessage: getOptionalInput("commit"), commitMessage: getOptionalInput("commit"),
hasPublishScript, hasPublishScript,
branch: getOptionalInput("branch"),
}); });
core.setOutput("pullRequestNumber", String(pullRequestNumber)); core.setOutput("pullRequestNumber", String(pullRequestNumber));
+3 -1
View File
@@ -299,6 +299,7 @@ type VersionOptions = {
commitMessage?: string; commitMessage?: string;
hasPublishScript?: boolean; hasPublishScript?: boolean;
prBodyMaxCharacters?: number; prBodyMaxCharacters?: number;
branch?: string;
}; };
type RunVersionResult = { type RunVersionResult = {
@@ -313,11 +314,12 @@ export async function runVersion({
commitMessage = "Version Packages", commitMessage = "Version Packages",
hasPublishScript = false, hasPublishScript = false,
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
branch,
}: VersionOptions): Promise<RunVersionResult> { }: VersionOptions): Promise<RunVersionResult> {
const octokit = setupOctokit(githubToken); const octokit = setupOctokit(githubToken);
let repo = `${github.context.repo.owner}/${github.context.repo.repo}`; 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 versionBranch = `changeset-release/${branch}`;
let { preState } = await readChangesetState(cwd); let { preState } = await readChangesetState(cwd);