Post Coverage Comment #308
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Post Coverage Comment | |
| on: | |
| workflow_run: | |
| workflows: ["Build and Deploy Snapshot"] | |
| types: [completed] | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| comment: | |
| runs-on: ubuntu-24.04 | |
| if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Download comment artifact | |
| uses: dawidd6/action-download-artifact@v12 | |
| with: | |
| name: pr-comment | |
| path: pr-comment/ | |
| run_id: ${{ github.event.workflow_run.id }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Post coverage comment | |
| run: | | |
| PR_NUMBER=$(cat pr-comment/pr-number.txt) | |
| COMMENT_BODY=$(cat pr-comment/comment-body.txt) | |
| # Find and delete existing comment | |
| COMMENT_ID=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json comments \ | |
| --jq '.comments[] | select(.body | contains("<!-- jacoco-coverage-comment -->")) | .id' | head -1) | |
| if [ -n "$COMMENT_ID" ]; then | |
| gh api -X DELETE "repos/${{ github.repository }}/issues/comments/$COMMENT_ID" || true | |
| fi | |
| # Post new comment | |
| gh pr comment $PR_NUMBER --repo ${{ github.repository }} --body "$COMMENT_BODY" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |