Skip to content

Commit

Permalink
Merge pull request #55 from github/changes-requested
Browse files Browse the repository at this point in the history
PRs in the `CHANGES_REQUESTED` state need to be treated as "not approved"
  • Loading branch information
GrantBirki authored Dec 12, 2024
2 parents 229efbe + af409b5 commit 8aa56c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
15 changes: 11 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions src/functions/prechecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ export async function prechecks(
// CI checks are set to be bypassed and the PR has not been reviewed
} else if (
commitStatus === 'skip_ci' &&
reviewDecision === 'REVIEW_REQUIRED'
(reviewDecision === 'REVIEW_REQUIRED' ||
reviewDecision === 'CHANGES_REQUESTED')
) {
message = `### ⚠️ Cannot proceed with operation\n\n> CI checks are not required for this operation but the PR has not been reviewed`
return {message: message, status: false}
Expand All @@ -257,7 +258,8 @@ export async function prechecks(

// If CI is passing but the PR has not been reviewed
} else if (
reviewDecision === 'REVIEW_REQUIRED' &&
(reviewDecision === 'REVIEW_REQUIRED' ||
reviewDecision === 'CHANGES_REQUESTED') &&
commitStatus === 'SUCCESS'
) {
message = `### ⚠️ Cannot proceed with operation\n\n> CI checks are passing but the PR has not been reviewed`
Expand All @@ -270,7 +272,8 @@ export async function prechecks(

// If CI is pending and the PR has not been reviewed
} else if (
reviewDecision === 'REVIEW_REQUIRED' &&
(reviewDecision === 'REVIEW_REQUIRED' ||
reviewDecision === 'CHANGES_REQUESTED') &&
commitStatus === 'PENDING'
) {
message = `### ⚠️ Cannot proceed with operation\n\n- reviewDecision: \`${reviewDecision}\`\n- commitStatus: \`${commitStatus}\`\n\n> CI is still in a pending state and reviews are also required for this operation`
Expand All @@ -282,7 +285,11 @@ export async function prechecks(
return {message: message, status: false}

// If CI is undefined and the PR has not been reviewed
} else if (reviewDecision === 'REVIEW_REQUIRED' && commitStatus === null) {
} else if (
(reviewDecision === 'REVIEW_REQUIRED' ||
reviewDecision === 'CHANGES_REQUESTED') &&
commitStatus === null
) {
message = `### ⚠️ Cannot proceed with operation\n\n- reviewDecision: \`${reviewDecision}\`\n- commitStatus: \`${commitStatus}\`\n\n> CI checks have not been defined but reviews are required for this operation`
return {message: message, status: false}

Expand Down

0 comments on commit 8aa56c8

Please sign in to comment.