Skip to content

Commit f7e41e0

Browse files
refactor: Simplify GitHub API call and enhance auto cleanup logic
1 parent 3555f2f commit f7e41e0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,12 @@ If you believe this is incorrect, please verify that your changes are in the cor
296296
"@
297297
try {
298298
Write-Host 'Adding comment to PR about skipped stages...'
299-
$null = Invoke-GitHubAPI -Method POST -ApiEndpoint "/repos/$owner/$repo/issues/$prNumber/comments" -Body (@{ body = $commentBody } | ConvertTo-Json)
299+
$apiParams = @{
300+
Method = 'POST'
301+
ApiEndpoint = "/repos/$owner/$repo/issues/$prNumber/comments"
302+
Body = @{ body = $commentBody } | ConvertTo-Json
303+
}
304+
$null = Invoke-GitHubAPI @apiParams
300305
Write-Host '✓ Comment added successfully'
301306
} catch {
302307
Write-Warning "Could not add PR comment (may need 'issues: write' permission): $_"
@@ -514,7 +519,10 @@ LogGroup 'Calculate Job Run Conditions:' {
514519
# Calculate if prereleases should be cleaned up:
515520
# True if (Release, merged PR to default branch, or Abandoned PR) AND user has AutoCleanup enabled (defaults to true)
516521
# Even if no important files changed, we still want to cleanup prereleases when merging to default branch
517-
$shouldAutoCleanup = (($releaseType -eq 'Release') -or ($isMergedPR -and $isTargetDefaultBranch) -or $isAbandonedPR) -and ($settings.Publish.Module.AutoCleanup -eq $true)
522+
$isReleaseOrMergedOrAbandoned = ($releaseType -eq 'Release') -or
523+
($isMergedPR -and $isTargetDefaultBranch) -or
524+
$isAbandonedPR
525+
$shouldAutoCleanup = $isReleaseOrMergedOrAbandoned -and ($settings.Publish.Module.AutoCleanup -eq $true)
518526

519527
# Update Publish.Module with computed release values
520528
$settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force

0 commit comments

Comments
 (0)