@@ -49,19 +49,56 @@ jobs:
4949 . scripts/utils.ps1
5050 $cmderVersion = Get-VersionStr
5151
52+ $refName = "${{ github.ref_name }}"
53+ $headRef = "${{ github.head_ref }}"
54+ $eventName = "${{ github.event_name }}"
55+ $prNumber = $null
56+ $actualBranchName = $refName
57+ $branchLink = "https://github.com/${{ github.repository }}/tree/$refName"
58+ $prLink = ""
59+ $workflowLink = "https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/tests.yml"
60+ $runLink = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
61+
62+ if ($refName -match '^(\d+)/(merge|head)$') {
63+ $prNumber = $Matches[1]
64+ # Use head_ref for the actual branch name if available
65+ if ($headRef) {
66+ $actualBranchName = $headRef
67+ }
68+ $branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
69+ $prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
70+ } elseif ($eventName -eq "pull_request") {
71+ # This is a pull request event
72+ $prNumber = "${{ github.event.pull_request.number }}"
73+ if ($headRef) {
74+ $actualBranchName = $headRef
75+ }
76+ $branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
77+ $prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
78+ }
79+
5280 $summary = @"
5381 ## ✅ Run Tests - Workflow Summary
5482
5583 ### Test Environment
5684 | Property | Value |
5785 | --- | --- |
58- | Repository | ``${{ github.repository }}`` |
59- | Branch | ``${{ github.ref_name }}`` |
60- | Commit | ``${{ github.sha }}`` |
86+ | Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
87+ | Source Branch | [``$actualBranchName``]($branchLink) |
88+ "@
89+
90+ if ($prNumber) {
91+ $summary += "| Pull Request | [#$prNumber]($prLink) |`n"
92+ }
93+
94+ $summary += @"
95+ | Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
96+ | Workflow | [``${{ github.workflow }}``]($workflowLink) |
97+ | Run | [``${{ github.run_id }}``]($runLink) |
6198 | Runner OS | ``${{ runner.os }}`` |
6299 | Cmder Version | **$cmderVersion** |
63100 | PowerShell Version | **$($PSVersionTable.PSVersion)** |
64- | Event | ``${{ github.event_name }} `` |
101+ | Event | ``$eventName `` |
65102 "@
66103
67104 $summary | Add-Content -Path $env:GITHUB_STEP_SUMMARY -Encoding utf8
0 commit comments