Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customize PR branch name #370

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/good-mice-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": patch
---

Allow customize branch name
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ node_modules
.parcel-cache
.cache
*.log

dist/
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
branchName:
description: Sets the branch name for the pull request. Default to `changeset-release/{{$github.ref_name}}`
required: false
branch:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
Comment on lines +31 to 35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those 2 inputs are too close to each other

required: false
Expand Down
63 changes: 63 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
commitMessage: getOptionalInput("commit"),
hasPublishScript,
branch: getOptionalInput("branch"),
branchName: getOptionalInput("branchName"),
});

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 @@ -300,6 +300,7 @@ type VersionOptions = {
hasPublishScript?: boolean;
prBodyMaxCharacters?: number;
branch?: string;
branchName?: string;
};

type RunVersionResult = {
Expand All @@ -315,12 +316,13 @@ export async function runVersion({
hasPublishScript = false,
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
branch,
branchName
}: VersionOptions): Promise<RunVersionResult> {
const octokit = setupOctokit(githubToken);

let repo = `${github.context.repo.owner}/${github.context.repo.repo}`;
branch = branch ?? github.context.ref.replace("refs/heads/", "");
let versionBranch = `changeset-release/${branch}`;
let versionBranch = branchName ?? `changeset-release/${branch}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem with this is that we rely on changeset-release/* being the versioning branch:
https://github.com/changesets/bot/blob/492290be72c42ae8f9ba85afe636a7b4520a9909/index.ts#L138-L142


let { preState } = await readChangesetState(cwd);

Expand Down