Skip to content

Commit 6e5cc15

Browse files
committed
ci: Fix posting coverage comments
1 parent e004ae4 commit 6e5cc15

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/test_rust.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ jobs:
164164
if: needs.changes.outputs.should_run == 'true'
165165
name: Coverage Report
166166
runs-on: ubuntu-24.04
167+
permissions:
168+
pull-requests: write
167169
steps:
168170
- uses: actions/checkout@v5
169171
with:
@@ -271,13 +273,23 @@ jobs:
271273
if: always()
272274
run: cat target/diff-cover/report.md >> $GITHUB_STEP_SUMMARY
273275

274-
- name: Comment
276+
- name: Generate comment
277+
id: generate_comment
275278
if: always()
276279
env:
277-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
278280
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
279281
run: |
280-
$COVERAGE_SCRIPT comment_report "target/diff-cover/report.json" "${{ github.event.pull_request.number }}" "${RUN_URL}"
282+
comment=$($COVERAGE_SCRIPT comment_report "target/diff-cover/report.json" "" "${RUN_URL}")
283+
echo "comment<<EOF" >> $GITHUB_OUTPUT
284+
echo "$comment" >> $GITHUB_OUTPUT
285+
echo "EOF" >> $GITHUB_OUTPUT
286+
287+
- name: Post comment
288+
if: always() && steps.generate_comment.outputs.comment != ''
289+
uses: thollander/actions-comment-pull-request@v3
290+
with:
291+
message: ${{ steps.generate_comment.outputs.comment }}
292+
comment-tag: coverage-report
281293

282294
dependencies:
283295
needs: changes

0 commit comments

Comments
 (0)