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

feat: add PR assignees support #962

Closed
wants to merge 1 commit into from
Closed
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 @@ -38,6 +38,7 @@ jobs:
| default_branch | Default branch | n/a |
| commit_title | Commit and PR title | `build(deps): npm audit fix` |
| labels | PR labels | `dependencies, javascript, security` |
| assignees | PR assignees | n/a |
| npm_args | Arguments for the `npm` command | n/a |

See [`action.yml`](action.yml).
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ inputs:
description: "PR labels"
required: false
default: "dependencies, javascript, security"
assignees:
description: "PR assignees"
required: false
npm_args:
description: "Arguments for the `npm` command"
required: false
Expand Down
18 changes: 16 additions & 2 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25312,7 +25312,8 @@ async function createOrUpdatePullRequest({
repository,
author,
email,
labels
labels,
assignees
}) {
const remote = `https://${author}:${token}@github.com/${repository}.git`;
const { owner, repo } = splitRepo(repository);
Expand Down Expand Up @@ -25361,6 +25362,17 @@ ${commitBody}`]);
labels
});
(0, import_core4.info)(`The labels were added successfully: ${newLabels.data.map((l) => l.name).join(", ")}`);
if (assignees.length > 0) {
const newAssignees = await octokit.rest.issues.addAssignees({
owner,
repo,
issue_number: newPull.data.number,
assignees
});
(0, import_core4.info)(
`The assignee(s) were added successfully: ${newAssignees.data.assignees?.map((a) => a.login).join(", ") ?? newAssignees.data.assignee}`
);
}
}
}

Expand Down Expand Up @@ -25484,6 +25496,7 @@ async function run() {
}
const author = core2.getInput("github_user");
const email = core2.getInput("github_email");
const assignees = commaSeparatedList(core2.getInput("assignees"));
return createOrUpdatePullRequest({
branch: core2.getInput("branch"),
token,
Expand All @@ -25494,7 +25507,8 @@ async function run() {
repository,
author,
email,
labels: commaSeparatedList(core2.getInput("labels"))
labels: commaSeparatedList(core2.getInput("labels")),
assignees
});
});
}
Expand Down
14 changes: 14 additions & 0 deletions lib/createOrUpdatePullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import splitRepo from "./utils/splitRepo.js";
* author: string,
* email: string,
* labels: string[],
* assignees: string[],
* }} params
*/
export default async function createOrUpdatePullRequest({
Expand All @@ -28,6 +29,7 @@ export default async function createOrUpdatePullRequest({
author,
email,
labels,
assignees,
}) {
const remote = `https://${author}:${token}@github.com/${repository}.git`;
const { owner, repo } = splitRepo(repository);
Expand Down Expand Up @@ -79,5 +81,17 @@ export default async function createOrUpdatePullRequest({
labels,
});
info(`The labels were added successfully: ${newLabels.data.map((l) => l.name).join(", ")}`);

if (assignees.length > 0) {
const newAssignees = await octokit.rest.issues.addAssignees({
owner,
repo,
issue_number: newPull.data.number,
assignees,
});
info(
`The assignee(s) were added successfully: ${newAssignees.data.assignees?.map((a) => a.login).join(", ") ?? newAssignees.data.assignee}`,
);
}
}
}
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ async function run() {

const author = core.getInput("github_user");
const email = core.getInput("github_email");
const assignees = commaSeparatedList(core.getInput("assignees"));

return createOrUpdatePullRequest({
branch: core.getInput("branch"),
Expand All @@ -108,6 +109,7 @@ async function run() {
author,
email,
labels: commaSeparatedList(core.getInput("labels")),
assignees,
});
});
}
Expand Down
Loading