# This is a follow up job that runs after the CI job has completed.
# It'll post a code coverage comment on pull requests.
name: Post Coverage Comment

on:
  workflow_run:
    workflows: ["Continuous Integration"]
    types:
      - completed

jobs:
  test:
    name: Post Coverage Comment
    runs-on: ubuntu-latest
    if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
    permissions:
      pull-requests: write
      contents: write
      actions: read
    steps:
      # !!! DO NOT run actions/checkout here, for security reasons !!!
      # For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
      - name: Post comment
        uses: py-cov-action/python-coverage-comment-action@v3
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}