Skip to content

Commit

Permalink
Use anySuccessful
Browse files Browse the repository at this point in the history
  • Loading branch information
mazhelez committed Nov 24, 2023
1 parent 011e967 commit 1dbbce6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,8 @@ function CheckBuildJobsInWorkflowRun {
$page = 1

$allSuccessful = $true
$buildJobsCount = 0
$anySuccessful = $false

# Get all build jobs in the workflow run
while($true) {
$jobsURI = "$api_url/repos/$repository/actions/runs/$WorkflowRunId/jobs?per_page=$per_page&page=$page"
Write-Host "- $jobsURI"
Expand All @@ -743,22 +742,20 @@ function CheckBuildJobsInWorkflowRun {

$buildJobs = @($workflowJobs.jobs | Where-Object { $_.name.StartsWith('Build ') })

if($buildJobs.conclusion -eq 'success') {
$anySuccessful = $true
}

if($buildJobs.conclusion -ne 'success') {
# If there is a build job that is not successful, there is not need to check further
$allSuccessful = $false
break
}

$buildJobsCount += $buildJobs.Count
$page += 1
}

if($buildJobsCount -eq 0) {
# No build jobs found, the workflow was probably cancelled
$allSuccessful = $false
}

return $allSuccessful
return ($allSuccessful -and $anySuccessful)
}

<#
Expand Down

0 comments on commit 1dbbce6

Please sign in to comment.