From d7d94b4fc3ce0fa908eb3f38bb063760c09dcc7f Mon Sep 17 00:00:00 2001 From: hirotomoyamada Date: Tue, 10 Mar 2026 02:18:22 +0900 Subject: [PATCH] feat(run): add support for assigning PRs via 'assignees' --- README.md | 1 + action.yml | 3 +++ src/index.ts | 1 + src/run.test.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ src/run.ts | 3 +++ 5 files changed, 50 insertions(+) diff --git a/README.md b/README.md index ebfda456..a0ed7c87 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This action for [Changesets](https://github.com/changesets/changesets) creates a - createGithubReleases - A boolean value to indicate whether to create Github releases after `publish` or not. Default to `true` - commitMode - Specifies the commit mode. Use `"git-cli"` to push changes using the Git CLI, or `"github-api"` to push changes via the GitHub API. When using `"github-api"`, all commits and tags are GPG-signed and attributed to the user or app who owns the `GITHUB_TOKEN`. Default to `git-cli`. - cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()` +- assignees - The assignees to assign the pull request to. ### Outputs diff --git a/action.yml b/action.yml index 89fe87a7..ef849cad 100644 --- a/action.yml +++ b/action.yml @@ -43,6 +43,9 @@ inputs: branch: description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided required: false + assignees: + description: The assignees to assign the pull request to. + 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 7021e49c..26473c45 100644 --- a/src/index.ts +++ b/src/index.ts @@ -146,6 +146,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; commitMessage: getOptionalInput("commit"), hasPublishScript, branch: getOptionalInput("branch"), + assignees: getOptionalInput("assignees"), }); core.setOutput("pullRequestNumber", String(pullRequestNumber)); diff --git a/src/run.test.ts b/src/run.test.ts index 90c9fc00..366157ff 100644 --- a/src/run.test.ts +++ b/src/run.test.ts @@ -277,4 +277,46 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis. /All release information have been omitted from this message, as the content exceeds the size limit/ ); }); + + it("creates PR with assignees", async () => { + let cwd = f.copy("simple-project"); + await linkNodeModules(cwd); + + mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] })); + + mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({ + data: { number: 123 }, + })); + + await writeChangesets( + [ + { + releases: [ + { + name: "simple-project-pkg-a", + type: "minor", + }, + { + name: "simple-project-pkg-b", + type: "minor", + }, + ], + summary: "Awesome feature", + }, + ], + cwd + ); + + await runVersion({ + octokit: setupOctokit("@@GITHUB_TOKEN"), + githubToken: "@@GITHUB_TOKEN", + git: new Git({ cwd }), + cwd, + assignees: "user1,user2", + }); + + expect(mockedGithubMethods.pulls.create.mock.calls[0][0].assignees).toEqual( + ["user1", "user2"] + ); + }); }); diff --git a/src/run.ts b/src/run.ts index 5ddb33e3..609ad456 100644 --- a/src/run.ts +++ b/src/run.ts @@ -260,6 +260,7 @@ type VersionOptions = { hasPublishScript?: boolean; prBodyMaxCharacters?: number; branch?: string; + assignees?: string; }; type RunVersionResult = { @@ -277,6 +278,7 @@ export async function runVersion({ hasPublishScript = false, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, branch = github.context.ref.replace("refs/heads/", ""), + assignees, }: VersionOptions): Promise { let versionBranch = `changeset-release/${branch}`; @@ -376,6 +378,7 @@ export async function runVersion({ head: versionBranch, title: finalPrTitle, body: prBody, + ...(assignees ? { assignees: assignees.split(",") } : {}), ...github.context.repo, });