Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 65 lines 2.5 kB view raw
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 steps: 29 - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 30 with: 31 script: | 32 // PRs from forks don't have any PRs associated by default. 33 // Thus, we request the PR number with an API call *to* the fork's repo. 34 // Multiple pull requests can be open from the same head commit, either via 35 // different base branches or head branches. 36 const { head_repository, head_sha, repository } = context.payload.workflow_run 37 await Promise.all( 38 (await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, { 39 owner: head_repository.owner.login, 40 repo: head_repository.name, 41 commit_sha: head_sha 42 })) 43 .filter(pull_request => pull_request.base.repo.id == repository.id) 44 .map(async (pull_request) => 45 Promise.all( 46 (await github.paginate(github.rest.pulls.listReviews, { 47 owner: context.repo.owner, 48 repo: context.repo.repo, 49 pull_number: pull_request.number 50 })).filter(review => 51 review.user.login == 'github-actions[bot]' && 52 review.state == 'DISMISSED' 53 ).map(review => github.graphql(` 54 mutation($node_id:ID!) { 55 minimizeComment(input: { 56 classifier: RESOLVED, 57 subjectId: $node_id 58 }) 59 { clientMutationId } 60 }`, 61 { node_id: review.node_id } 62 )) 63 ) 64 ) 65 )