Skip to content

Commit

Permalink
Adding code coverage comment in the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachinbisht27 committed Sep 13, 2023
1 parent f8d0016 commit d583981
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/unit-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,9 @@ jobs:
echo "![Coverage](https://img.shields.io/badge/coverage-$(grep -oP 'covered="(\K[^"]+)' coverage.xml)%25-brightgreen)" >> coverage_comment.txt
echo "Coverage details are available [here](./coverage.xml)." >> coverage_comment.txt
# Set up the comment payload in a JSON file
echo '{"body": "'$(cat coverage_comment.txt | sed ':a;N;$!ba;s/\n/\\n/g')'"}' > comment_payload.json
# Post the comment using the GitHub API
# Post the comment using the GitHub API with PR number directly
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d @comment_payload.json \
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments"
-d "{\"body\": \"$(cat coverage_comment.txt | sed ':a;N;$!ba;s/\n/\\n/g')\"}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/comments"

0 comments on commit d583981

Please sign in to comment.