name: PR Coverage Comment on: workflow_run: workflows: ["container project - PR build"] types: - completed permissions: contents: read jobs: comment: name: Post coverage comment runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} permissions: contents: read actions: read pull-requests: write steps: - name: Download coverage artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} pattern: pr-coverage-* merge-multiple: true path: pr-coverage-data id: download-artifact continue-on-error: true - name: Check artifact exists if: steps.download-artifact.outcome == 'success' id: check-artifact run: | if [ -f pr-coverage-data/pr-number.txt ]; then echo "found=true" >> $GITHUB_OUTPUT else echo "No coverage artifact found — coverage job may have failed." echo "found=false" >> $GITHUB_OUTPUT fi - name: Validate and post comment if: steps.check-artifact.outputs.found == 'true' env: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} run: | PR_NUMBER=$(cat pr-coverage-data/pr-number.txt) grep -qxE '[0-9]+' <<< "$PR_NUMBER" || { echo "Invalid PR number: ${PR_NUMBER}"; exit 1; } UNIT=$(cat pr-coverage-data/unit-line-coverage.txt) grep -qxE '[0-9]+(\.[0-9]+)?' <<< "$UNIT" || { echo "Invalid unit coverage: ${UNIT}"; exit 1; } INTEGRATION=$(cat pr-coverage-data/integration-line-coverage.txt) grep -qxE '[0-9]+(\.[0-9]+)?' <<< "$INTEGRATION" || { echo "Invalid integration coverage: ${INTEGRATION}"; exit 1; } COMBINED=$(cat pr-coverage-data/combined-line-coverage.txt) grep -qxE '[0-9]+(\.[0-9]+)?' <<< "$COMBINED" || { echo "Invalid combined coverage: ${COMBINED}"; exit 1; } MARKER="" BODY=$(cat <