I'm working on a Github Action with the Github API endpoint for the list of reviews but it returns the whole history, including dismissals and comments, but the only ones I need are the ones where the state is "APPROVED".
The issue is that if the PR has more than 100 review objects (100 being the max per page), I'm unable to find the approved objects which will be on the following page since it returns in chronological order.
Is there any other way to get the pull request review approved state?
My code is the following:
async function evaluateReviews() { const result = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews', { owner: owner, repo: repo, pull_number: pullNumber }); const numberOfApprovalsRequired = core.getInput('number-of-approvals'); const reviews = result.data var approvals = 0 reviews.forEach((item, i) => { if (item.state == "APPROVED") { approvals += 1; } }); if (approvals >= numberOfApprovalsRequired) { addApprovedLabel(); } }