Skip to content

Commit

Permalink
update check-status method
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Nov 1, 2023
1 parent 094b82a commit 46179b3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
17 changes: 13 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.

17 changes: 13 additions & 4 deletions src/functions/check-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export async function checkStatus(
mustBeApproved
) {
let statusOK = true

// If we are running in a mode that checks for passing CI or approved PRs, then we need to check the status of the PR
if (mustBeGreen || mustBeApproved) {
core.info('Checking green status: ' + branch)
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) {
Expand Down Expand Up @@ -36,17 +38,23 @@ export async function checkStatus(

// Check for CI status
if (mustBeGreen) {
const [{commit}] = result.repository.pullRequest.commits.nodes
if (commit.statusCheckRollup) {
const [{commit}] = result?.repository?.pullRequest?.commits?.nodes

// If CI checks have been defined for the given pull request / commit
if (commit?.statusCheckRollup) {
const state = commit.statusCheckRollup.state
core.info('Validating status: ' + state)
if (state !== 'SUCCESS') {
core.info('Discarding ' + branch + ' with status ' + state)
statusOK = false
}

// If no CI checks have been defined for the given pull request / commit
} else {
core.info('No status check associated with branch: ' + branch)
statusOK = false
core.info('No status check(s) associated with branch: ' + branch)
core.debug(
'If no checks have been defined, then we default to success for CI checks'
)
}
}

Expand All @@ -67,5 +75,6 @@ export async function checkStatus(
}
}
}

return statusOK
}

0 comments on commit 46179b3

Please # to comment.