diff --git a/README.md b/README.md index 2ff354fd..7e7071f5 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/action.yml b/action.yml index cd6c6db0..f5da2f86 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/index.cjs b/dist/index.cjs index 7a0bda49..7758439b 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -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); @@ -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}` + ); + } } } @@ -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, @@ -25494,7 +25507,8 @@ async function run() { repository, author, email, - labels: commaSeparatedList(core2.getInput("labels")) + labels: commaSeparatedList(core2.getInput("labels")), + assignees }); }); } diff --git a/lib/createOrUpdatePullRequest.js b/lib/createOrUpdatePullRequest.js index b9a0c8d1..cd3adc00 100644 --- a/lib/createOrUpdatePullRequest.js +++ b/lib/createOrUpdatePullRequest.js @@ -15,6 +15,7 @@ import splitRepo from "./utils/splitRepo.js"; * author: string, * email: string, * labels: string[], + * assignees: string[], * }} params */ export default async function createOrUpdatePullRequest({ @@ -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); @@ -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}`, + ); + } } } diff --git a/lib/index.js b/lib/index.js index 48423d05..6be4ae08 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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"), @@ -108,6 +109,7 @@ async function run() { author, email, labels: commaSeparatedList(core.getInput("labels")), + assignees, }); }); }