Skip to content

Commit

Permalink
Feature: Allow custom branch (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestognw committed Mar 18, 2024
1 parent e245972 commit f2660aa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/happy-singers-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": patch
---

Allow customize PR `branch` field
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 3 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ type VersionOptions = {
commitMessage?: string;
hasPublishScript?: boolean;
prBodyMaxCharacters?: number;
branch?: string;
};

type RunVersionResult = {
Expand All @@ -313,11 +314,12 @@ export async function runVersion({
commitMessage = "Version Packages",
hasPublishScript = false,
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
branch,
}: VersionOptions): Promise<RunVersionResult> {
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);
Expand Down

0 comments on commit f2660aa

Please sign in to comment.