@@ -145,39 +145,24 @@ jobs:
145145 Write-Output "::warning::Target branch '$prBranch' has been changed manually - skipping updater to avoid overwriting these changes."
146146 }
147147
148- - name : Fetch an existing PR
149- if : ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }}
150- uses : octokit/request-action@89697eb6635e52c6e1e5559f15b5c91ba5100cb0 # v2.1.9
151- id : existing-pr-request
152- with :
153- route : GET /repos/${{ github.repository }}/pulls?base={base}&head={head}
154- head : ' ${{ github.repository }}:${{ steps.root.outputs.prBranch }}'
155- base : ' ${{ steps.root.outputs.baseBranch }}'
156- env :
157- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
158-
159148 - name : Parse the existing PR URL
160149 if : ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }}
161150 id : existing-pr
151+ env :
152+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
162153 run : |
163- $data = @'
164- ${{ steps.existing-pr-request.outputs.data }}
165- '@
166-
167- $prCount = $($data | jq '. | length')
168-
169- if ($prCount -eq '0')
154+ $urls = @(gh api 'repos/${{ github.repository }}/pulls?base=${{ steps.root.outputs.baseBranch }}&head=${{ github.repository_owner }}:${{ steps.root.outputs.prBranch }}' --jq '.[].html_url')
155+ if ($urls.Length -eq 0)
170156 {
171157 "url=" | Tee-Object $env:GITHUB_OUTPUT -Append
172158 }
173- elseif ($prCount -eq '1' )
159+ elseif ($urls.Length -eq 1 )
174160 {
175- $url = $($data | Select-String '"html_url": +"(.*/pull/.*)"').Matches[0].Groups[1].Value
176- "url=$url" | Tee-Object $env:GITHUB_OUTPUT -Append
161+ "url=$($urls[0])" | Tee-Object $env:GITHUB_OUTPUT -Append
177162 }
178163 else
179164 {
180- throw "Unexpected number of PRs matched: $prCount "
165+ throw "Unexpected number of PRs matched ($($urls.Length)) : $urls "
181166 }
182167
183168 - run : git --no-pager diff
0 commit comments