Merge pull request #2 from potiuk/support-for-pull-request-review
Add support for pull_request_review type and added PR pagination
diff --git a/dist/index.js b/dist/index.js
index f67f8c6..ed5e583 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1486,12 +1486,12 @@
return __awaiter(this, void 0, void 0, function* () {
// Finds Pull request for this workflow run
core.info(`\nFinding PR request id for: owner: ${owner}, Repo:${repo}, Head:${headRepo}:${headBranch}.\n`);
- const pullRequests = yield octokit.pulls.list({
+ const pullRequests = yield octokit.paginate(octokit.pulls.list({
owner,
repo,
head: `${headRepo}:${headBranch}`
- });
- for (const pullRequest of pullRequests.data) {
+ }));
+ for (const pullRequest of pullRequests) {
core.info(`\nComparing: ${pullRequest.number} sha: ${pullRequest.head.sha} with expected: ${headSha}.\n`);
if (pullRequest.head.sha === headSha) {
core.info(`\nFound PR: ${pullRequest.number}\n`);
@@ -1515,7 +1515,8 @@
`Head branch: ${sourceRun.head_branch} ` +
`Event: ${sourceRun.event}, Head sha: ${sourceRun.head_sha}, url: ${sourceRun.url}`);
let pullRequest = null;
- if (sourceRun.event === 'pull_request') {
+ if (sourceRun.event === 'pull_request' ||
+ sourceRun.event === 'pull_request_review') {
pullRequest = yield findPullRequest(octokit, owner, repo, sourceRun.head_repository.owner.login, sourceRun.head_branch, sourceRun.head_sha);
}
return [
diff --git a/src/main.ts b/src/main.ts
index 63d0c23..b545f5f 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -43,12 +43,14 @@
core.info(
`\nFinding PR request id for: owner: ${owner}, Repo:${repo}, Head:${headRepo}:${headBranch}.\n`
)
- const pullRequests = await octokit.pulls.list({
- owner,
- repo,
- head: `${headRepo}:${headBranch}`
- })
- for (const pullRequest of pullRequests.data) {
+ const pullRequests = await octokit.paginate(
+ octokit.pulls.list({
+ owner,
+ repo,
+ head: `${headRepo}:${headBranch}`
+ })
+ )
+ for (const pullRequest of pullRequests) {
core.info(
`\nComparing: ${pullRequest.number} sha: ${pullRequest.head.sha} with expected: ${headSha}.\n`
)
@@ -82,7 +84,10 @@
`Event: ${sourceRun.event}, Head sha: ${sourceRun.head_sha}, url: ${sourceRun.url}`
)
let pullRequest: rest.PullsListResponseItem | null = null
- if (sourceRun.event === 'pull_request') {
+ if (
+ sourceRun.event === 'pull_request' ||
+ sourceRun.event === 'pull_request_review'
+ ) {
pullRequest = await findPullRequest(
octokit,
owner,