Skip to content

Commit 55251f7

Browse files
Show actual branch name and separate PR row in repository information
Agent-Logs-Url: https://github.com/cmderdev/cmder/sessions/7ac9b75c-de48-4c0b-98db-108cc3423c0e Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
1 parent 0983e9b commit 55251f7

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = @"
@@ -72,7 +88,8 @@ jobs:
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

Comments
 (0)