Skip to content

Commit 57ca418

Browse files
fix: write step summary directly from action.ps1
Always call Build-SummaryReport and write to $GITHUB_STEP_SUMMARY via Add-Content rather than relying on the workflow to echo the coverageSummary output. The echo approach mangles multiline markdown (backticks, dollar signs, quotes), causing the step summary to appear empty. Remove the now-redundant 'Add Coverage Job Summary' / 'Publish Coverage Workflow Build Summary' steps from all three example workflows to avoid duplicating the content. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9ffbd01 commit 57ca418

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,3 @@ jobs:
6969
echo "coverage_percentage : ${{ steps.jacoco_reporter.outputs.coverage_percentage }}"
7070
echo "coveragePercentageString : ${{ steps.jacoco_reporter.outputs.coveragePercentageString }}"
7171
72-
- name: Publish Coverage Workflow Build Summary
73-
run: echo "${{ steps.jacoco_reporter.outputs.coverageSummary }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/one.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ jobs:
5858
fail_below_threshold: false
5959
publish_only_summary: true
6060

61-
- name: Add Coverage Job Summary
62-
run: echo "${{ steps.jacoco_reporter.outputs.coverageSummary }}" >> $GITHUB_STEP_SUMMARY
63-
6461
- name: Upload Code Coverage Artifacts
6562
uses: actions/upload-artifact@v4
6663
with:

.github/workflows/two.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ jobs:
5151
fail_below_threshold: false
5252
publish_only_summary: false
5353

54-
- name: Add Coverage Job Summary
55-
run: echo "${{ steps.jacoco_reporter.outputs.coverageSummary }}" >> $GITHUB_STEP_SUMMARY
56-
5754
- name: Get the Coverage info
5855
run: |
5956
echo "Total coverage coverage-overall ${{ steps.jacoco.outputs.coverage-overall }}"

action.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ function Build-SummaryReport {
124124
[System.IO.File]::WriteAllText($script:coverage_summary_path, $combined.ToString())
125125
}
126126

127+
function Write-StepSummary([string]$content) {
128+
if ($env:GITHUB_STEP_SUMMARY -and $content) {
129+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $content
130+
}
131+
}
132+
127133
## ── Coverage Analysis ─────────────────────────────────────────────────────────
128134

129135
function Parse-CoverageXML {
@@ -319,9 +325,11 @@ if ($publishOnlySummary) {
319325
} else {
320326
Build-CoverageReport
321327
}
322-
if ($skipCheckRun) {
323-
Build-SummaryReport
324-
}
328+
# Always build the compact job-summary format and write it directly to
329+
# $GITHUB_STEP_SUMMARY. This is more reliable than relying on the workflow
330+
# to echo the coverageSummary output (echo mangles multiline markdown).
331+
Build-SummaryReport
332+
Write-StepSummary -content ([System.IO.File]::ReadAllText($script:coverage_summary_path))
325333

326334
# Step 2 ── Parse coverage data and compute metrics
327335
Parse-CoverageXML

0 commit comments

Comments
 (0)