1name: Dismissed review 2 3on: 4 workflow_run: 5 workflows: 6 - Review dismissed 7 types: [completed] 8 9concurrency: 10 group: dismissed-review-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }} 11 cancel-in-progress: true 12 13permissions: 14 pull-requests: write 15 16defaults: 17 run: 18 shell: bash 19 20jobs: 21 # The `check-cherry-picks` workflow creates review comments which reviewers 22 # are encouraged to manually dismiss if they're not relevant. 23 # When a CI-generated review is dismissed, this job automatically minimizes 24 # it, preventing it from cluttering the PR. 25 minimize: 26 name: Minimize as resolved 27 runs-on: ubuntu-24.04-arm 28 timeout-minutes: 2 29 steps: 30 - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 31 with: 32 script: | 33 // PRs from forks don't have any PRs associated by default. 34 // Thus, we request the PR number with an API call *to* the fork's repo. 35 // Multiple pull requests can be open from the same head commit, either via 36 // different base branches or head branches. 37 const { head_repository, head_sha, repository } = context.payload.workflow_run 38 await Promise.all( 39 (await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, { 40 owner: head_repository.owner.login, 41 repo: head_repository.name, 42 commit_sha: head_sha 43 })) 44 .filter(pull_request => pull_request.base.repo.id == repository.id) 45 .map(async (pull_request) => 46 Promise.all( 47 (await github.paginate(github.rest.pulls.listReviews, { 48 owner: context.repo.owner, 49 repo: context.repo.repo, 50 pull_number: pull_request.number 51 })).filter(review => 52 review.user?.login == 'github-actions[bot]' && 53 review.state == 'DISMISSED' 54 ).map(review => github.graphql(` 55 mutation($node_id:ID!) { 56 minimizeComment(input: { 57 classifier: RESOLVED, 58 subjectId: $node_id 59 }) 60 { clientMutationId } 61 }`, 62 { node_id: review.node_id } 63 )) 64 ) 65 ) 66 )