diff --git a/.github/workflows/auto-response.yml b/.github/workflows/auto-response.yml index c979d120c4..e0c14845aa 100644 --- a/.github/workflows/auto-response.yml +++ b/.github/workflows/auto-response.yml @@ -105,6 +105,26 @@ jobs: } } + const pullRequest = context.payload.pull_request; + if (pullRequest) { + const labelCount = pullRequest.labels?.length ?? 0; + if (labelCount > 20) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequest.number, + body: "Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.", + }); + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequest.number, + state: "closed", + }); + return; + } + } + const labelName = context.payload.label?.name; if (!labelName) { return;