diff --git a/.github/workflows/auto-response.yml b/.github/workflows/auto-response.yml index 8fb76b99b9e..a40149b7ccb 100644 --- a/.github/workflows/auto-response.yml +++ b/.github/workflows/auto-response.yml @@ -261,6 +261,8 @@ jobs: }; const triggerLabel = "trigger-response"; + const activePrLimitLabel = "r: too-many-prs"; + const activePrLimitOverrideLabel = "r: too-many-prs-override"; const target = context.payload.issue ?? context.payload.pull_request; if (!target) { return; @@ -448,6 +450,10 @@ jobs: return; } + if (pullRequest && labelSet.has(activePrLimitOverrideLabel)) { + labelSet.delete(activePrLimitLabel); + } + const rule = rules.find((item) => labelSet.has(item.label)); if (!rule) { return; diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 2e8e1ec59b0..8de54a416f8 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -213,6 +213,7 @@ jobs: } const activePrLimitLabel = "r: too-many-prs"; + const activePrLimitOverrideLabel = "r: too-many-prs-override"; const activePrLimit = 10; const labelColor = "B60205"; const labelDescription = `Author has more than ${activePrLimit} active PRs in this repo`; @@ -221,12 +222,37 @@ jobs: return; } + const currentLabels = await github.paginate(github.rest.issues.listLabelsOnIssue, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequest.number, + per_page: 100, + }); + const labelNames = new Set( - (pullRequest.labels ?? []) + currentLabels .map((label) => (typeof label === "string" ? label : label?.name)) .filter((name) => typeof name === "string"), ); + if (labelNames.has(activePrLimitOverrideLabel)) { + if (labelNames.has(activePrLimitLabel)) { + try { + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequest.number, + name: activePrLimitLabel, + }); + } catch (error) { + if (error?.status !== 404) { + throw error; + } + } + } + return; + } + const ensureLabelExists = async () => { try { await github.rest.issues.getLabel({