Skip to content

Commit

Permalink
Consider CICD workflow run with no build jobs unsuccessful (#835)
Browse files Browse the repository at this point in the history
_Issue_:
A CICD workflow run with no build jobs is considered _successful_.

_Solution_:
Check if the CICD has at least one build job.
  • Loading branch information
mazhelez authored Nov 27, 2023
1 parent addf9b9 commit 8df6c4a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ function CheckBuildJobsInWorkflowRun {
$page = 1

$allSuccessful = $true
$anySuccessful = $false

while($true) {
$jobsURI = "$api_url/repos/$repository/actions/runs/$WorkflowRunId/jobs?per_page=$per_page&page=$page"
Expand All @@ -738,22 +739,23 @@ function CheckBuildJobsInWorkflowRun {
# No more jobs, breaking out of the loop
break
}

$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
}

if(-not $allSuccessful) {
# there is a non-successful build job, no need to check further
break
}

$page += 1
}

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

<#
Expand Down

0 comments on commit 8df6c4a

Please sign in to comment.