@@ -123,26 +123,63 @@ function Get-PublishConfiguration {
123123function Get-GitHubPullRequest {
124124 <#
125125 . SYNOPSIS
126- Reads and validates the GitHub pull request from the event payload.
126+ Reads normalized pull request context from settings, with event payload fallback .
127127
128128 . DESCRIPTION
129- Loads the GitHub event from the input override or from the event path file. On a
130- pull_request event it returns the pull request head ref and labels. On any other
131- event (for example workflow_dispatch or schedule) there is no pull request, so it
132- returns $null and the caller resolves the current version without a version bump.
129+ Uses the normalized context produced by Get-PSModuleSettings so push events can use
130+ pull request labels and head ref resolved from the commit SHA. Raw pull_request event
131+ payloads remain supported for callers that invoke this action directly.
133132
134133 . OUTPUTS
135- PSCustomObject with HeadRef and Labels properties for a pull_request event, or
136- $null when the event has no pull request (non-PR events) .
134+ PSCustomObject with HeadRef and Labels properties, or $null when no release context
135+ is available .
137136
138137 . EXAMPLE
139138 $pullRequest = Get-GitHubPullRequest
140139 #>
141140 [CmdletBinding ()]
142141 [OutputType ([PSCustomObject ])]
143- param ()
142+ param (
143+ # The JSON string containing normalized workflow settings.
144+ [Parameter (Mandatory )]
145+ [ValidateNotNullOrEmpty ()]
146+ [string ] $SettingsJson
147+ )
144148
145149 LogGroup ' Event information' {
150+ $settings = $SettingsJson | ConvertFrom-Json
151+ $pr = $settings.Context.PullRequest
152+ if ($pr ) {
153+ $labels = @ ($pr.Labels )
154+
155+ Write-Host ' Using normalized pull request context from settings.'
156+ Write-Host ' -------------------------------------------------'
157+ Write-Host ([PSCustomObject ]@ {
158+ PRNumber = $pr.Number
159+ PRHeadRef = $pr.HeadRef
160+ Labels = $labels -join ' , '
161+ } | Format-List | Out-String )
162+ Write-Host ' -------------------------------------------------'
163+
164+ return [PSCustomObject ]@ {
165+ Number = $pr.Number
166+ HeadRef = $pr.HeadRef
167+ Labels = $labels
168+ }
169+ }
170+
171+ if (
172+ $settings.Context.IsPushToDefaultBranch -and
173+ $settings.Publish.Module.ReleaseType -eq ' Release'
174+ ) {
175+ Write-Host ' Using explicitly enabled direct-push release context from settings.'
176+ return [PSCustomObject ]@ {
177+ Number = $null
178+ HeadRef = $settings.Context.DefaultBranch
179+ Labels = @ ()
180+ }
181+ }
182+
146183 $eventJsonInput = $env: PSMODULE_RESOLVE_PSMODULEVERSION_INPUT_EventJson
147184 $githubEvent = if (-not [string ]::IsNullOrWhiteSpace($eventJsonInput )) {
148185 $eventJsonInput | ConvertFrom-Json
@@ -152,8 +189,8 @@ function Get-GitHubPullRequest {
152189
153190 $pr = $githubEvent.pull_request
154191 if (-not $pr ) {
155- Write-Host ' GitHub event does not contain pull_request data (non-PR event, e.g. workflow_dispatch or schedule) .'
156- Write-Host ' No pull request context is available; the caller keeps the current version without a bump.'
192+ Write-Host ' No normalized or event pull request context is available .'
193+ Write-Host ' The caller keeps the current version without a bump.'
157194 return $null
158195 }
159196
@@ -168,6 +205,7 @@ function Get-GitHubPullRequest {
168205 Write-Host ' -------------------------------------------------'
169206
170207 [PSCustomObject ]@ {
208+ Number = $pr.number
171209 HeadRef = $pr.head.ref
172210 Labels = $labels
173211 }
0 commit comments