Skip to content

Commit 5ab2c44

Browse files
committed
Allow specifying a bot-assignee
This is a new optional input, which, if specified, will automatically assign any bot-authored PRs to the specified GH user.
1 parent b44bb23 commit 5ab2c44

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: "Pull Assign"
22
description: "a Github action to assign a PR to the author"
3+
inputs:
4+
bot-assignee:
5+
description: A user to assign bot-authored PRs to.
6+
required: false
37
runs:
48
using: node20
59
main: "dist/index.js"

src/action.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const github = require('@actions/github')
33
const { Octokit } = require("@octokit/action")
44

55
async function run() {
6+
const botAssignee = core.getInput('bot-assignee') || null
7+
68
const client = new Octokit()
79
const owner = github.context.payload.repository.owner.login
810
const repo = github.context.payload.repository.name
@@ -17,7 +19,15 @@ async function run() {
1719

1820
if (!assignees || assignees.length === 0) {
1921
if (author.is_bot || (author.type && author.type === 'Bot')) {
20-
console.log(`PR was created by a bot (${author.login}). No assignee added.`)
22+
if (botAssignee) {
23+
console.log(`PR was created by a bot (${author.login}). Assigning ${botAssignee}.`)
24+
await client.request(
25+
`POST /repos/${owner}/${repo}/issues/${issue_number}/assignees`,
26+
{ owner, repo, issue_number, assignees: [botAssignee] }
27+
)
28+
} else {
29+
console.log(`PR was created by a bot (${author.login}), but no bot-assignee was provided. No assignee added.`)
30+
}
2131
} else {
2232
console.log(`PR was created by a human (${author.login}). Assigning them.`)
2333
await client.request(

0 commit comments

Comments
 (0)