Skip to content

Commit 9c811d0

Browse files
🩹[Patch]: Fix repo linting on merge to main (#2)
This release updates the logic for determining pull request states in the `scripts/main.ps1` script, making the conditions for open, updated, abandoned, and merged pull requests more precise and adding improved logging for GitHub event inputs. - Fixes PSModule/Process-PSModule#256 **Improvements to PR state detection:** * Refined the `$isOpenOrUpdatedPR` condition to trigger only for `'opened'`, `'reopened'`, or `'synchronize'` actions, making it more accurate than the previous logic. * Updated the `$isMergedPR` condition to require both the `'closed'` action and that the PR is marked as merged, preventing false positives. **Logging enhancements:** * Added output of relevant GitHub event environment variables at the start of the job run conditions calculation for easier debugging and traceability.
1 parent 77c3c59 commit 9c811d0

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

scripts/main.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,17 @@ $settings | Add-Member -MemberType NoteProperty -Name WorkingDirectory -Value $w
192192
# Calculate job run conditions
193193
LogGroup 'Calculate Job Run Conditions:' {
194194
# Common conditions
195+
Write-Host 'GitHub event inputs:'
196+
[pscustomobject]@{
197+
GITHUB_EVENT_NAME = $env:GITHUB_EVENT_NAME
198+
GITHUB_EVENT_ACTION = $env:GITHUB_EVENT_ACTION
199+
GITHUB_EVENT_PULL_REQUEST_MERGED = $env:GITHUB_EVENT_PULL_REQUEST_MERGED
200+
} | Format-List | Out-String
201+
195202
$isPR = $env:GITHUB_EVENT_NAME -eq 'pull_request'
196-
$isOpenOrUpdatedPR = $isPR -and $env:GITHUB_EVENT_ACTION -ne 'closed'
203+
$isOpenOrUpdatedPR = $isPR -and $env:GITHUB_EVENT_ACTION -in @('opened', 'reopened', 'synchronize')
197204
$isAbandonedPR = $isPR -and $env:GITHUB_EVENT_ACTION -eq 'closed' -and $env:GITHUB_EVENT_PULL_REQUEST_MERGED -ne 'true'
198-
$isMergedPR = $isPR -and $env:GITHUB_EVENT_PULL_REQUEST_MERGED -eq 'true'
205+
$isMergedPR = $isPR -and $env:GITHUB_EVENT_ACTION -eq 'closed' -and $env:GITHUB_EVENT_PULL_REQUEST_MERGED -eq 'true'
199206
$isNotAbandonedPR = -not $isAbandonedPR
200207

201208
[pscustomobject]@{

0 commit comments

Comments
 (0)