Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
42 changes: 42 additions & 0 deletions src/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
);
});
});
3 changes: 3 additions & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ type VersionOptions = {
hasPublishScript?: boolean;
prBodyMaxCharacters?: number;
branch?: string;
assignees?: string;
};

type RunVersionResult = {
Expand All @@ -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<RunVersionResult> {
let versionBranch = `changeset-release/${branch}`;

Expand Down Expand Up @@ -376,6 +378,7 @@ export async function runVersion({
head: versionBranch,
title: finalPrTitle,
body: prBody,
...(assignees ? { assignees: assignees.split(",") } : {}),
...github.context.repo,
});

Expand Down