@@ -152,14 +152,14 @@ jobs:
152152 $prNumber = if ('${{ github.event.pull_request.number }}' -eq '') { '' } else { '${{ github.event.pull_request.number }}' }
153153 & .\scripts\ProcessSvgDiagrams.ps1 -DiffReportFilename "${{env.DiffReportFilename}}" -GitUserName "${{env.GitUserName}}" -GitUserEmail "${{env.GitUserEmail}}" -PullRequestNumber "$prNumber" -RepositoryName "${{github.repository}}"
154154 - name : Publish DiffReport.xml
155- uses : actions/upload-artifact@v4
155+ uses : actions/upload-artifact@v7.0.0
156156 with :
157157 name : DiffReport
158158 path : .\*.xml
159159 retention-days : 2
160160
161161 - name : Publish SessionFile
162- uses : actions/upload-artifact@v4
162+ uses : actions/upload-artifact@v7.0.0
163163 with :
164164 name : SessionFile
165165 path : .\*.ltsfs
@@ -196,26 +196,72 @@ jobs:
196196 - name : Extract branch name
197197 id : extract_branch
198198 run : |
199- Write-Output "branch=$env:GITHUB_HEAD_REF" >> $env:GITHUB_OUTPUT
199+ $branch = git branch --show-current
200+ Write-Output "branch=$branch" >> $env:GITHUB_OUTPUT
201+ Write-Output "Current branch: $branch"
200202
201203 - name : Print Session URL
202204 run : |
203205 Write-Output "${{steps.uploadSession.outputs.SessionURL}}"
204206
205- - name : Find Pull Request
206- uses : juliangruber/ find-pull-request-action@v1
207- id : find-pull-request
207+ - name : Find and validate Pull Request
208+ id : find-pr
209+ uses : actions/github-script@v8
208210 with :
209- branch : ${{steps.extract_branch.outputs.branch }}
211+ result-encoding : string
212+ script : |
213+ // Extract branch name from github.ref
214+ const ref = context.ref;
215+ const branch = ref.startsWith('refs/heads/') ? ref.slice('refs/heads/'.length) : ref;
216+ console.log(`GitHub ref: ${ref}`);
217+ console.log(`Extracted branch: ${branch}`);
218+
219+ // First check if we have a PR context from the event
220+ if (context.payload.pull_request) {
221+ const pr = context.payload.pull_request;
222+ console.log(`Found PR from event context: #${pr.number}`);
223+ core.setOutput('pr_exists', 'true');
224+ core.setOutput('pr_number', pr.number);
225+ return;
226+ }
227+
228+ console.log(`Searching for open PRs with head ref: ${branch}`);
229+
230+ // Search for open PRs with matching head ref
231+ const prs = await github.rest.pulls.list({
232+ owner: context.repo.owner,
233+ repo: context.repo.repo,
234+ state: 'open',
235+ per_page: 100
236+ });
237+
238+ console.log(`Found ${prs.data.length} open PRs`);
239+
240+ // Filter PRs by matching head branch
241+ const matchingPrs = prs.data.filter(pr => {
242+ const headRef = pr.head.ref;
243+ console.log(` PR #${pr.number}: head=${headRef}`);
244+ return headRef === branch;
245+ });
246+
247+ if (matchingPrs.length > 0) {
248+ const pr = matchingPrs[0];
249+ console.log(`✓ Found PR #${pr.number} with matching branch`);
250+ core.setOutput('pr_exists', 'true');
251+ core.setOutput('pr_number', pr.number);
252+ } else {
253+ console.log(`✗ No open PR found for branch: ${branch}`);
254+ core.setOutput('pr_exists', 'false');
255+ }
210256
211257 - name : Post Finish message in PR
212- if : ${{ steps.find-pull-request .outputs.number != ' ' }}
213- uses : actions/github-script@v7
258+ if : ${{ steps.find-pr .outputs.pr_exists == 'true ' }}
259+ uses : actions/github-script@v8
214260 with :
215261 script : |
262+ const prNumber = ${{steps.find-pr.outputs.pr_number}};
216263 const COMMENT_MARKER = '<!-- polarion-review -->';
217264 const body = COMMENT_MARKER + '\nPolarion vs Model comparison in current Branch\n${{steps.uploadSession.outputs.SfsFileNameLinks}}\n\n${{ steps.processSvgs.outputs.svgLinksMarkdown }}${{steps.pcsDiff.outputs.CommitID}}\n\nChanged Requirements:\n${{steps.diffreport.outputs.ModifiedRequirements}}';
218- const prNumber = ${{steps.find-pull-request.outputs.number}};
219265 const { data: comments } = await github.rest.issues.listComments({
220266 owner: context.repo.owner,
221267 repo: context.repo.repo,
@@ -247,7 +293,7 @@ jobs:
247293 Write-Output "${{steps.uploadSession.outputs.SfsFileNameLinks}}" >> $env:GITHUB_STEP_SUMMARY
248294
249295 - name : Publish Model Artifact
250- uses : actions/upload-artifact@v4
296+ uses : actions/upload-artifact@v7.0.0
251297 with :
252298 name : ModelFiles
253299 path : .\*.qeax
0 commit comments