# This workflow is triggered on PR being closed.
# It dispatches workflow on CompFuzzCI repository, where the bugs found in the PR head is discarded from the database.

name: Updating CompFuzzCI on PR Closed
on:
  pull_request:
    branches:
      - master
    types: [closed]
  
jobs:
  UpdatePRClosed:
    if: github.event.pull_request.base.ref == 'master' && github.event.pull_request.head.repo.owner.login == 'dafny-lang'
    runs-on: ubuntu-latest
    steps:
      - name: Trigger CompFuzzCI
        uses: actions/github-script@v7
        with:
            github-token: ${{ secrets.COMPFUZZCI_PAT }}
            script: |
              await github.rest.actions.createWorkflowDispatch({
                  owner: 'CompFuzzCI',
                  repo: 'DafnyCompilerFuzzer',
                  workflow_id: 'update_pr_close.yaml',
                  ref: 'main',
                  inputs: {
                      pr_head_ref: '${{github.event.pull_request.head.ref}}' 
                  }
              })