Skip to content

Commit 7a0b93f

Browse files
committed
chore: add assign reminder feature
Signed-off-by: exploreriii <[email protected]>
1 parent faf4567 commit 7a0b93f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/scripts/bot-gfi-assign-on-comment.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ Once you find one you like, comment \`/assign\` to get started.`
6666
);
6767
}
6868

69+
// HELPERS FOR PEOPLE THAT WANT TO BE ASSIGNED BUT DID NOT READ INSTRUCTIONS
70+
const ASSIGN_REMINDER_MARKER = '<!-- GFI assign reminder -->';
71+
72+
function buildAssignReminder(username) {
73+
return `${ASSIGN_REMINDER_MARKER}
74+
👋 Hi @${username}!
75+
76+
If you’d like to work on this **Good First Issue**, just comment:
77+
78+
\`\`\`
79+
/assign
80+
\`\`\`
81+
82+
and you’ll be automatically assigned. Feel free to ask questions here if anything is unclear!`;
83+
}
6984

7085
/// START OF SCRIPT ///
7186
module.exports = async ({ github, context }) => {
@@ -102,6 +117,40 @@ module.exports = async ({ github, context }) => {
102117
}
103118

104119
if (!commentRequestsAssignment(comment.body)) {
120+
// Only remind if:
121+
// - GFI
122+
// - unassigned
123+
// - reminder not already posted
124+
if (
125+
issueIsGoodFirstIssue(issue) &&
126+
!issue.assignees?.length
127+
) {
128+
const comments = await github.paginate(
129+
github.rest.issues.listComments,
130+
{
131+
owner,
132+
repo,
133+
issue_number: issue.number,
134+
per_page: 100,
135+
}
136+
);
137+
138+
const reminderAlreadyPosted = comments.some(c =>
139+
c.body?.includes(ASSIGN_REMINDER_MARKER)
140+
);
141+
142+
if (!reminderAlreadyPosted) {
143+
await github.rest.issues.createComment({
144+
owner,
145+
repo,
146+
issue_number: issue.number,
147+
body: buildAssignReminder(comment.user.login),
148+
});
149+
150+
console.log('[gfi-assign] Posted /assign reminder');
151+
}
152+
}
153+
105154
console.log('[gfi-assign] Exit: comment does not request assignment');
106155
return;
107156
}

0 commit comments

Comments
 (0)