@@ -192,17 +192,46 @@ $settings | Add-Member -MemberType NoteProperty -Name WorkingDirectory -Value $w
192192# Calculate job run conditions
193193LogGroup ' Calculate Job Run Conditions:' {
194194 # Common conditions
195+ $eventData = $null
196+ try {
197+ $eventData = Get-GitHubEventData - ErrorAction Stop
198+ } catch {
199+ if (-not [string ]::IsNullOrEmpty($env: GITHUB_EVENT_PATH ) -and (Test-Path - Path $env: GITHUB_EVENT_PATH )) {
200+ $eventData = Get-Content - Path $env: GITHUB_EVENT_PATH - Raw | ConvertFrom-Json
201+ }
202+ }
203+
204+ LogGroup ' GitHub Event Data' {
205+ if ($null -ne $eventData ) {
206+ Write-Host ($eventData | ConvertTo-Json - Depth 10 | Out-String )
207+ } else {
208+ Write-Host ' No event data available.'
209+ }
210+ }
211+
212+ $pullRequestAction = if ($null -ne $eventData.action ) {
213+ $eventData.action
214+ } else {
215+ $env: GITHUB_EVENT_ACTION
216+ }
217+
218+ $pullRequestIsMerged = if ($null -ne $eventData.pull_request -and $null -ne $eventData.pull_request.merged ) {
219+ [bool ]$eventData.pull_request.merged
220+ } else {
221+ $false
222+ }
223+
195224 Write-Host ' GitHub event inputs:'
196225 [pscustomobject ]@ {
197226 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
227+ GITHUB_EVENT_ACTION = $pullRequestAction
228+ GITHUB_EVENT_PULL_REQUEST_MERGED = $pullRequestIsMerged
200229 } | Format-List | Out-String
201230
202231 $isPR = $env: GITHUB_EVENT_NAME -eq ' pull_request'
203- $isOpenOrUpdatedPR = $isPR -and $env: GITHUB_EVENT_ACTION -in @ (' opened' , ' reopened' , ' synchronize' )
204- $isAbandonedPR = $isPR -and $env: GITHUB_EVENT_ACTION -eq ' closed' -and $env: GITHUB_EVENT_PULL_REQUEST_MERGED -ne ' true'
205- $isMergedPR = $isPR -and $env: GITHUB_EVENT_ACTION -eq ' closed' -and $env: GITHUB_EVENT_PULL_REQUEST_MERGED -eq ' true'
232+ $isOpenOrUpdatedPR = $isPR -and $pullRequestAction -in @ (' opened' , ' reopened' , ' synchronize' )
233+ $isAbandonedPR = $isPR -and $pullRequestAction -eq ' closed' -and $pullRequestIsMerged -ne $ true
234+ $isMergedPR = $isPR -and $pullRequestAction -eq ' closed' -and $pullRequestIsMerged -eq $ true
206235 $isNotAbandonedPR = -not $isAbandonedPR
207236
208237 [pscustomobject ]@ {
0 commit comments