Skip to content

Commit c03aa9b

Browse files
committed
fix: prevent commenting and auto-closing bot PRs
Signed-off-by: Parv Ninama <ninamaparv@gmail.com>
1 parent 5d8c71c commit c03aa9b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.github/scripts/linked_issue_enforce.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const requireAuthorAssigned = (process.env.REQUIRE_AUTHOR_ASSIGNED || 'true').to
88
const getDaysOpen = (pr) =>
99
Math.floor((Date.now() - new Date(pr.created_at)) / (24 * 60 * 60 * 1000));
1010

11+
// Check if the PR author is a bot
12+
const isBotAuthor = (pr) => pr.user?.type === 'Bot';
13+
1114
// Check if the PR author is assigned to the issue
1215
const isAuthorAssigned = (issue, login) => {
1316
if (!issue || issue.state?.toUpperCase() !== 'OPEN') return false;
@@ -104,6 +107,12 @@ module.exports = async ({ github, context }) => {
104107
console.log(`Evaluating ${prs.length} open PRs\n`);
105108

106109
for (const pr of prs) {
110+
111+
if (isBotAuthor(pr)) {
112+
console.log(`PR #${pr.number} authored by bot (${pr.user.login}). Skipping.`);
113+
continue;
114+
}
115+
107116
const days = getDaysOpen(pr);
108117
if (days < daysBeforeClose) {
109118
console.log(`PR #${pr.number} link: ${pr.html_url} is only ${days} days old. Skipping.`);

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
189189
- Enhance TopicInfo `__str__` method and tests with additional coverage, and update the format_key function in `key_format.py` to handle objects with a _to_proto method.
190190

191191
### Fixed
192+
- Prevented linkbot from commenting on or auto-closing bot-authored pull requests. (#1516)
192193
- Respect `dry-run` input in `bot-community-calls.yml` workflow (#1425)
193194
- Updated LinkBot regex in the GitHub Actions bot script to support "Closes" and "Resolves" keywords for improved PR body-link detection (#1465)
194195
- Fixed CodeRabbit plan trigger workflow running multiple times when issues are created with multiple labels by switching to labeled event trigger only. (#1427)

0 commit comments

Comments
 (0)