From c518e768c5aa57aa979cc0bd3d3a9d64f99178b1 Mon Sep 17 00:00:00 2001 From: prenaissance Date: Mon, 3 Jun 2024 11:09:19 +0300 Subject: [PATCH 1/3] feat: add baseBranch option --- action.yml | 3 +++ src/index.ts | 1 + src/run.ts | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 86b97909..ede14137 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,9 @@ inputs: branch: description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided required: false + baseBranch: + description: Sets the base branch for the pull request. Default to the branch the action runs on 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 194204dc..c37353a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,6 +110,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; commitMessage: getOptionalInput("commit"), hasPublishScript, branch: getOptionalInput("branch"), + baseBranch: getOptionalInput("baseBranch"), }); core.setOutput("pullRequestNumber", String(pullRequestNumber)); diff --git a/src/run.ts b/src/run.ts index 326b9618..a50cddde 100644 --- a/src/run.ts +++ b/src/run.ts @@ -300,6 +300,7 @@ type VersionOptions = { hasPublishScript?: boolean; prBodyMaxCharacters?: number; branch?: string; + baseBranch?: string; }; type RunVersionResult = { @@ -315,11 +316,13 @@ export async function runVersion({ hasPublishScript = false, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, branch, + baseBranch, }: VersionOptions): Promise { const octokit = setupOctokit(githubToken); let repo = `${github.context.repo.owner}/${github.context.repo.repo}`; branch = branch ?? github.context.ref.replace("refs/heads/", ""); + baseBranch ??= branch; let versionBranch = `changeset-release/${branch}`; let { preState } = await readChangesetState(cwd); @@ -396,7 +399,7 @@ export async function runVersion({ if (existingPullRequests.data.length === 0) { core.info("creating pull request"); const { data: newPullRequest } = await octokit.rest.pulls.create({ - base: branch, + base: baseBranch, head: versionBranch, title: finalPrTitle, body: prBody, From 85e75a4dc22a1453c429b25bb7733842195a7302 Mon Sep 17 00:00:00 2001 From: prenaissance Date: Mon, 3 Jun 2024 11:57:55 +0300 Subject: [PATCH 2/3] chore: add changeset --- .changeset/unlucky-lies-brush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/unlucky-lies-brush.md diff --git a/.changeset/unlucky-lies-brush.md b/.changeset/unlucky-lies-brush.md new file mode 100644 index 00000000..f327f49a --- /dev/null +++ b/.changeset/unlucky-lies-brush.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": minor +--- + +add option 'baseBranch' From 571b28560f595bf6ae613447f62dc6b8cc81c7ba Mon Sep 17 00:00:00 2001 From: prenaissance Date: Sat, 30 Nov 2024 12:09:07 +0200 Subject: [PATCH 3/3] docs: document new action input --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cc7f703b..c0fdbaf6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a - setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` - createGithubReleases - A boolean value to indicate whether to create Github releases after `publish` or not. Default to `true` - cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()` +- baseBranch - The branch to create the pull request against. Default to the branch the action is running on. ### Outputs