workflows/review-{dismissed,minimize}: init

This brings back the "minimize CI reviews after dismissal" job that was
previously removed. The first time around, we had a single job triggered
by the `pull_request_review` event. This lacks permission to do
meaningful stuff, though.

This time, we trigger an empty no-op job on `pull_request_review` and
then run a second workflow on `workflow_run`. This can run with the
proper permissions.

Changed files
+82
.github
+65
.github/workflows/dismissed-review.yml
···
+
name: Dismissed review
+
+
on:
+
workflow_run:
+
workflows:
+
- Review dismissed
+
types: [completed]
+
+
concurrency:
+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.run_id }}
+
cancel-in-progress: true
+
+
permissions:
+
pull-requests: write
+
+
defaults:
+
run:
+
shell: bash
+
+
jobs:
+
# The `check-cherry-picks` workflow creates review comments which reviewers
+
# are encouraged to manually dismiss if they're not relevant.
+
# When a CI-generated review is dismissed, this job automatically minimizes
+
# it, preventing it from cluttering the PR.
+
minimize:
+
name: Minimize as resolved
+
runs-on: ubuntu-24.04-arm
+
steps:
+
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
+
with:
+
script: |
+
// PRs from forks don't have any PRs associated by default.
+
// Thus, we request the PR number with an API call *to* the fork's repo.
+
// Multiple pull requests can be open from the same head commit, either via
+
// different base branches or head branches.
+
const { head_repository, head_sha, repository } = context.payload.workflow_run
+
await Promise.all(
+
(await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, {
+
owner: head_repository.owner.login,
+
repo: head_repository.name,
+
commit_sha: head_sha
+
}))
+
.filter(pull_request => pull_request.base.repo.id == repository.id)
+
.map(async (pull_request) =>
+
Promise.all(
+
(await github.paginate(github.rest.pulls.listReviews, {
+
owner: context.repo.owner,
+
repo: context.repo.repo,
+
pull_number: pull_request.number
+
})).filter(review =>
+
review.user.login == 'github-actions[bot]' &&
+
review.state == 'DISMISSED'
+
).map(review => github.graphql(`
+
mutation($node_id:ID!) {
+
minimizeComment(input: {
+
classifier: RESOLVED,
+
subjectId: $node_id
+
})
+
{ clientMutationId }
+
}`,
+
{ node_id: review.node_id }
+
))
+
)
+
)
+
)
+17
.github/workflows/review-dismissed.yml
···
+
name: Review dismissed
+
+
on:
+
pull_request_review:
+
types: [dismissed]
+
+
permissions: {}
+
+
defaults:
+
run:
+
shell: bash
+
+
jobs:
+
trigger:
+
runs-on: ubuntu-24.04-arm
+
steps:
+
- run: echo This is a no-op only used as a trigger for workflow_run.