Skip to content

Commit 44a6367

Browse files
authored
Allow bot approvals (#7774)
Since we use renovate-approval[bot] to approve renovate PRs. We still require 2 approvals for any non-whitelisted bot-authored PRs. But this will fix the queue of renovate PRs Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent ace3d8e commit 44a6367

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

.github/workflows/approvals.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,20 @@ jobs:
2323
pull_number: pr.number,
2424
});
2525
26-
// Count unique human approvals (latest review per user)
26+
// Determine if PR author is a bot/GitHub Actions
27+
const authorType = pr.user.type; // 'Bot' vs 'User'
28+
const authorLogin = pr.user.login; // e.g. 'github-actions[bot]'
29+
const isBot = authorType === 'Bot' || authorLogin.endsWith('[bot]');
30+
const oneApprovalBotAuthors = new Set(['renovate[bot]']);
31+
32+
// Count unique approvals, including bot approvals.
2733
const latestByUser = {};
2834
for (const review of reviews.data) {
29-
if (review.user.type === 'Bot') continue;
3035
latestByUser[review.user.login] = review.state;
3136
}
3237
const approvalCount = Object.values(latestByUser)
3338
.filter(state => state === 'APPROVED').length;
3439
35-
// Determine if PR author is a bot/GitHub Actions
36-
const authorType = pr.user.type; // 'Bot' vs 'User'
37-
const authorLogin = pr.user.login; // e.g. 'github-actions[bot]'
38-
const isBot = authorType === 'Bot' || authorLogin.endsWith('[bot]');
39-
const oneApprovalBotAuthors = new Set(['renovate[bot]']);
40-
4140
const required = isBot && !oneApprovalBotAuthors.has(authorLogin) ? 2 : 1;
4241
4342
console.log(`PR author: ${authorLogin} (${authorType}), isBot: ${isBot}`);
@@ -46,7 +45,7 @@ jobs:
4645
4746
if (isBot && (approvalCount < required)) {
4847
core.setFailed(
49-
`This PR needs ${required} human approval(s) but has ${approvalCount}. ` +
48+
`This PR needs ${required} approval(s) but has ${approvalCount}. ` +
5049
`(Author is ${isBot ? 'a bot' : 'human'})`
5150
);
5251
}

0 commit comments

Comments
 (0)