Skip to content

Commit f2660aa

Browse files
authored
Feature: Allow custom branch (#255)
1 parent e245972 commit f2660aa

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

.changeset/happy-singers-hammer.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/action": patch
3+
---
4+
5+
Allow customize PR `branch` field

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ inputs:
2828
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
2929
required: false
3030
default: true
31+
branch:
32+
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
33+
required: false
3134
outputs:
3235
published:
3336
description: A boolean value to indicate whether a publishing is happened or not

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
109109
prTitle: getOptionalInput("title"),
110110
commitMessage: getOptionalInput("commit"),
111111
hasPublishScript,
112+
branch: getOptionalInput("branch"),
112113
});
113114

114115
core.setOutput("pullRequestNumber", String(pullRequestNumber));

src/run.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ type VersionOptions = {
299299
commitMessage?: string;
300300
hasPublishScript?: boolean;
301301
prBodyMaxCharacters?: number;
302+
branch?: string;
302303
};
303304

304305
type RunVersionResult = {
@@ -313,11 +314,12 @@ export async function runVersion({
313314
commitMessage = "Version Packages",
314315
hasPublishScript = false,
315316
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
317+
branch,
316318
}: VersionOptions): Promise<RunVersionResult> {
317319
const octokit = setupOctokit(githubToken);
318320

319321
let repo = `${github.context.repo.owner}/${github.context.repo.repo}`;
320-
let branch = github.context.ref.replace("refs/heads/", "");
322+
branch = branch ?? github.context.ref.replace("refs/heads/", "");
321323
let versionBranch = `changeset-release/${branch}`;
322324

323325
let { preState } = await readChangesetState(cwd);

0 commit comments

Comments
 (0)