# Updates a pull request based on the corresponding mutation testing analysis
# performed by the `pitest-analyze-pr.yml` workflow. See
# https://blog.pitest.org/oss-pitest-pr/ for details.
name: "Mutation testing: post results"
on:
  workflow_run:
    workflows: ["Mutation testing"]
    types:
      - completed
permissions:
  actions: read
jobs:
  update-pr:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    permissions:
      actions: read
      checks: write
      contents: read
      pull-requests: write
    runs-on: ubuntu-24.04
    steps:
      - name: Install Harden-Runner
        uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
        with:
          disable-sudo: true
          egress-policy: block
          allowed-endpoints: >
            api.adoptium.net:443
            api.github.com:443
            github.com:443
            objects.githubusercontent.com:443
            repo.maven.apache.org:443
      - name: Check out code and set up JDK and Maven
        uses: s4u/setup-maven-action@4f7fb9d9675e899ca81c6161dadbba0189a4ebb1 # v1.18.0
        with:
          java-version: 17.0.13
          java-distribution: temurin
          maven-version: 3.9.9
      - name: Download Pitest analysis artifact
        uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe # v3.1.4
        with:
          workflow: ${{ github.event.workflow_run.workflow_id }}
          name: pitest-reports
          path: ./target/pit-reports-ci
      - name: Update PR
        run: mvn -DrepoToken="${{ secrets.GITHUB_TOKEN }}" pitest-github:updatePR
