@@ -48,19 +48,35 @@ jobs:
4848 $cmderVersion = Get-VersionStr
4949 $buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
5050
51- # Determine branch link (handle PR merge refs)
52- $branchName = "${{ github.ref_name }}"
51+ # Determine branch and PR information
52+ $refName = "${{ github.ref_name }}"
53+ $headRef = "${{ github.head_ref }}"
54+ $eventName = "${{ github.event_name }}"
55+ $prNumber = $null
56+ $actualBranchName = $refName
5357 $branchLink = ""
54- if ($branchName -match '^(\d+)/(merge|head)$') {
55- # This is a PR merge/head ref, link to the PR
58+ $prLink = ""
59+
60+ # Check if this is a PR merge ref (e.g., "3061/merge")
61+ if ($refName -match '^(\d+)/(merge|head)$') {
5662 $prNumber = $Matches[1]
57- $branchLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
58- } elseif ("${{ github.event_name }}" -eq "pull_request") {
59- # This is a pull request event, link to the PR
60- $branchLink = "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
63+ # Use head_ref for the actual branch name if available
64+ if ($headRef) {
65+ $actualBranchName = $headRef
66+ }
67+ $branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
68+ $prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
69+ } elseif ($eventName -eq "pull_request") {
70+ # This is a pull request event
71+ $prNumber = "${{ github.event.pull_request.number }}"
72+ if ($headRef) {
73+ $actualBranchName = $headRef
74+ }
75+ $branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
76+ $prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
6177 } else {
6278 # Regular branch, link to the branch tree
63- $branchLink = "https://github.com/${{ github.repository }}/tree/${{ github.ref_name }} "
79+ $branchLink = "https://github.com/${{ github.repository }}/tree/$refName "
6480 }
6581
6682 $summary = @"
7288 | Property | Value |
7389 | --- | --- |
7490 | Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
75- | Branch | [``$branchName``]($branchLink) |
91+ | Branch | [``$actualBranchName``]($branchLink) |
92+ $(if ($prNumber) { "| Pull Request | [#$prNumber]($prLink) |" })
7693 | Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
7794 | Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
7895 | Workflow | ``${{ github.workflow }}`` |
0 commit comments