lol

workflows/labels: count approving reviewers, not reviews (#416668)

authored by

Wolfgang Walther and committed by
GitHub
f917df32 fc56d019

+6 -5
+6 -5
.github/workflows/labels.yml
··· 96 96 name == '12.approved-by: package-maintainer' 97 97 ) 98 98 99 - const approvals = 99 + const approvals = new Set( 100 100 (await github.paginate(github.rest.pulls.listReviews, { 101 101 owner: context.repo.owner, 102 102 repo: context.repo.repo, ··· 104 104 })) 105 105 .filter(review => review.state == 'APPROVED') 106 106 .map(review => review.user.id) 107 + ) 107 108 108 - const maintainers = Object.keys( 109 + const maintainers = new Set(Object.keys( 109 110 JSON.parse(await readFile('comparison/maintainers.json', 'utf-8')) 110 - ) 111 + )) 111 112 112 113 // And the labels that should be there 113 114 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') 116 117 117 118 // Remove the ones not needed anymore 118 119 await Promise.all(