Skip to content

Commit

Permalink
Deduping approvals to search for unique releases (#548)
Browse files Browse the repository at this point in the history
* Deduping approvals to search for unique releases

Co-authored-by: snehabandla <[email protected]>
  • Loading branch information
snehabandla and snehabandla authored Feb 5, 2021
1 parent 375e84b commit 55234a7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/CreateRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,25 @@ while(-Not($lastRelease -eq $currentRelease)) {
# Validate that only one release is pending approval - any others should be approved, rejected or queued.
if($approval.Count -gt 1) {
$pendingApprovals = "Pending releases for approval: "
$pendingReleaseIds = @()
foreach ($pendingApproval in $approval) {
$pendingApprovals += $pendingApproval.release.name + " "
if($pendingReleaseIds.Contains($pendingApproval.release.id))
{
# Ensure pending approvals are associated with unique releases
$pendingApprovals += $pendingApproval.release.name + " "
}
else {
$pendingReleaseIds += $pendingApproval.release.id
}
}

$multipleApprovalsError = "Error: More than 1 approval at a time was unexpected $pendingApprovals"
log $multipleApprovalsError
throw $multipleApprovalsError
if($pendingReleaseIds.Count -gt 1)
{
# If approvals are not associated with unique releases, throw.
$multipleApprovalsError = "Error: More than 1 approval ($approval.Count) at a time was unexpected $pendingApprovals"
log $multipleApprovalsError
throw $multipleApprovalsError
}
}
elseif($approval.Count -eq 0) {
# If there are no pending approvals, exit as there are no new changes to release.
Expand Down

0 comments on commit 55234a7

Please sign in to comment.