Skip to content

Commit f917df3

Browse files
workflows/labels: count approving reviewers, not reviews (#416668)
2 parents fc56d01 + 2e03351 commit f917df3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

.github/workflows/labels.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,24 @@ jobs:
9696
name == '12.approved-by: package-maintainer'
9797
)
9898
99-
const approvals =
99+
const approvals = new Set(
100100
(await github.paginate(github.rest.pulls.listReviews, {
101101
owner: context.repo.owner,
102102
repo: context.repo.repo,
103103
pull_number: pull_request.number
104104
}))
105105
.filter(review => review.state == 'APPROVED')
106106
.map(review => review.user.id)
107+
)
107108
108-
const maintainers = Object.keys(
109+
const maintainers = new Set(Object.keys(
109110
JSON.parse(await readFile('comparison/maintainers.json', 'utf-8'))
110-
)
111+
))
111112
112113
// And the labels that should be there
113114
const after = JSON.parse(await readFile('comparison/changed-paths.json', 'utf-8')).labels
114-
if (approvals.length > 0) after.push(`12.approvals: ${approvals.length > 2 ? '3+' : approvals.length}`)
115-
if (maintainers.some(id => approvals.includes(id))) after.push('12.approved-by: package-maintainer')
115+
if (approvals.size > 0) after.push(`12.approvals: ${approvals.size > 2 ? '3+' : approvals.size}`)
116+
if (Array.from(maintainers).some(approvals.has)) after.push('12.approved-by: package-maintainer')
116117
117118
// Remove the ones not needed anymore
118119
await Promise.all(

0 commit comments

Comments
 (0)