From fc4054446f7ea88898f695778be77aa6f5c50cca Mon Sep 17 00:00:00 2001 From: Coco Sheng Date: Wed, 13 May 2026 14:43:07 -0400 Subject: [PATCH] ci: suppress bot comments during standard triage maintenance (#27006) --- .github/scripts/apply-issue-labels.cjs | 52 ++++++++++++++++++- .../gemini-scheduled-issue-triage.yml | 5 +- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/.github/scripts/apply-issue-labels.cjs b/.github/scripts/apply-issue-labels.cjs index f875a7ed38..61f8a6b4b7 100644 --- a/.github/scripts/apply-issue-labels.cjs +++ b/.github/scripts/apply-issue-labels.cjs @@ -104,6 +104,51 @@ module.exports = async ({ github, context, core }) => { labelsToAdd = [...new Set(labelsToAdd)]; labelsToRemove = [...new Set(labelsToRemove)]; + // Fetch existing labels to auto-resolve conflicts + try { + const { data: issueData } = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + }); + const existingLabels = issueData.labels.map((l) => + typeof l === 'string' ? l : l.name, + ); + + const hasNewArea = labelsToAdd.some((l) => l.startsWith('area/')); + if (hasNewArea) { + const existingAreas = existingLabels.filter((l) => + l.startsWith('area/'), + ); + labelsToRemove.push(...existingAreas); + } + + const hasNewPriority = labelsToAdd.some((l) => l.startsWith('priority/')); + if (hasNewPriority) { + const existingPriorities = existingLabels.filter((l) => + l.startsWith('priority/'), + ); + labelsToRemove.push(...existingPriorities); + } + + const hasNewKind = labelsToAdd.some((l) => l.startsWith('kind/')); + if (hasNewKind) { + const existingKinds = existingLabels.filter((l) => + l.startsWith('kind/'), + ); + labelsToRemove.push(...existingKinds); + } + + // Re-deduplicate and filter out labels we are trying to add + labelsToRemove = [...new Set(labelsToRemove)].filter( + (l) => !labelsToAdd.includes(l), + ); + } catch (e) { + core.warning( + `Failed to fetch existing labels for #${issueNumber}: ${e.message}`, + ); + } + // Enforce mutually exclusive area labels const areaLabelsToAdd = labelsToAdd.filter((l) => l.startsWith('area/')); if (areaLabelsToAdd.length > 1) { @@ -166,9 +211,12 @@ module.exports = async ({ github, context, core }) => { ); } - if (entry.explanation || entry.effort_analysis) { + if ( + (entry.explanation && process.env.SUPPRESS_COMMENT !== 'true') || + entry.effort_analysis + ) { let commentBody = ''; - if (entry.explanation) { + if (entry.explanation && process.env.SUPPRESS_COMMENT !== 'true') { commentBody += entry.explanation; } if (entry.effort_analysis) { diff --git a/.github/workflows/gemini-scheduled-issue-triage.yml b/.github/workflows/gemini-scheduled-issue-triage.yml index 66ed56cdb5..363c8ca3c0 100644 --- a/.github/workflows/gemini-scheduled-issue-triage.yml +++ b/.github/workflows/gemini-scheduled-issue-triage.yml @@ -1,10 +1,6 @@ name: '📋 Gemini Scheduled Issue Triage' on: - issues: - types: - - 'opened' - - 'reopened' schedule: - cron: '0 * * * *' # Runs every hour workflow_dispatch: @@ -391,6 +387,7 @@ jobs: env: REPOSITORY: '${{ github.repository }}' LABELS_OUTPUT: '${{ steps.gemini_standard_issue_analysis.outputs.summary }}' + SUPPRESS_COMMENT: 'true' uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' with: github-token: '${{ steps.generate_token.outputs.token }}'