Skip to content

Commit 9aa6985

Browse files
aristathclaude
andcommitted
Fix JSON interpolation in github-script action
The coverage changes JSON was being corrupted when passed through GitHub Actions expression syntax ${{ }}. The expression parser was mangling the multiline JSON with curly braces. Solution: Pass the JSON through an environment variable instead. This avoids the expression parser and preserves the JSON intact. Before: const changesStr = `${{ steps.coverage_diff.outputs.coverage_changes }}`; After: const changesStr = process.env.COVERAGE_CHANGES || '{}'; This should now properly display the file-level coverage changes in the collapsible <details> section of the PR comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1c4e3fa commit 9aa6985

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/code-coverage.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ jobs:
313313
- name: Comment PR with coverage
314314
if: github.event_name == 'pull_request'
315315
uses: actions/github-script@v7
316+
env:
317+
COVERAGE_CHANGES: ${{ steps.coverage_diff.outputs.coverage_changes }}
316318
with:
317319
github-token: ${{ secrets.GITHUB_TOKEN }}
318320
script: |
@@ -323,13 +325,14 @@ jobs:
323325
const coverageEmoji = current >= 80 ? '🎉' : current >= 60 ? '📈' : current >= 40 ? '📊' : '📉';
324326
const status = diff >= -0.5 ? '✅' : '⚠️';
325327
326-
// Parse coverage changes JSON
328+
// Parse coverage changes JSON from environment variable
327329
let changesJson = {};
328330
try {
329-
const changesStr = `${{ steps.coverage_diff.outputs.coverage_changes }}`;
330-
changesJson = changesStr ? JSON.parse(changesStr) : {};
331+
const changesStr = process.env.COVERAGE_CHANGES || '{}';
332+
changesJson = JSON.parse(changesStr);
331333
} catch (e) {
332334
console.log('Failed to parse coverage changes:', e);
335+
console.log('Raw value:', process.env.COVERAGE_CHANGES);
333336
}
334337
335338
// Build detailed changes section

0 commit comments

Comments
 (0)