From 87d59989bd4700c114d8278576429a79ca06013a Mon Sep 17 00:00:00 2001 From: David Sanders Date: Wed, 23 Aug 2023 19:21:17 -0700 Subject: [PATCH] Revert "chore: return early in addOrUpdateAPIReviewCheck for forks (#146)" This reverts commit f3b42b17135222f2d5dd9ef13ad0062b7a0ba208. --- src/api-review-state.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/api-review-state.ts b/src/api-review-state.ts index 7887c54..8fb55e2 100644 --- a/src/api-review-state.ts +++ b/src/api-review-state.ts @@ -62,28 +62,29 @@ export async function addOrUpdateAPIReviewCheck(octokit: Context['octokit'], pr: type CommentOrReview = ListReviewsItem & ListCommentsItem; + const fork = pr.head.repo.fork; const owner = pr.base.repo.owner.login; const repo = pr.head.repo.name; - if (pr.head.repo.fork) { + if (fork) { log( 'addOrUpdateAPIReviewCheck', LogLevel.INFO, `${pr.number} is a fork - checks will not be created or updated`, ); - // If the PR is a fork PR, return early as the Checks API doesn't work. - return; } // Fetch the latest API Review check for the PR. - const checkRun = ( - await octokit.checks.listForRef({ - ref: pr.head.sha, - per_page: 100, - owner, - repo, - }) - ).data.check_runs.find((run) => run.name === API_REVIEW_CHECK_NAME); + const checkRun = fork + ? null + : ( + await octokit.checks.listForRef({ + ref: pr.head.sha, + per_page: 100, + owner, + repo, + }) + ).data.check_runs.find((run) => run.name === API_REVIEW_CHECK_NAME); const resetToNeutral = async () => { if (!checkRun) return; @@ -219,6 +220,9 @@ export async function addOrUpdateAPIReviewCheck(octokit: Context['octokit'], pr: const users = { approved, declined, requestedChanges }; + // If the PR is a fork PR, return early as the Checks API doesn't work. + if (fork) return users; + // Update the GitHub Check with appropriate API review information. const updateCheck = async ( opts: Omit<