Skip to content

Add comment with code-coverage to PR #115

Add comment with code-coverage to PR

Add comment with code-coverage to PR #115

name: Add comment with code-coverage to PR
on:
workflow_run:
workflows: ['CI']
branches-ignore: ['dependabot/**']
types: [completed]
jobs:
add-comment-with-code-coverage:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout project
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Download cobertura.xml file
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
with:
run_id: ${{github.event.workflow_run.id }}
name: cobertura
path: .
- name: Download PR_NUMBER
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
with:
run_id: ${{github.event.workflow_run.id }}
name: PR_NUMBER
path: .
- name: Extract PR number
id: extract-pr-number
run: |
pr_number=$(cat ./PR_NUMBER)
echo "PR_NUMBER=$pr_number" >> $GITHUB_OUTPUT
- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: cobertura-coverage.xml
badge: true
format: markdown
output: both
thresholds: '60 80'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@f61b6cf21ef2fcc468f4345cdfcc9bda741d2343 # v2.6.2
with:
recreate: true
header: coverage
number: ${{ steps.extract-pr-number.outputs.PR_NUMBER }}
path: code-coverage-results.md