From 17b37144a96da13bf7a0917411bc1d34142609d7 Mon Sep 17 00:00:00 2001 From: Bryan Morgan Date: Sun, 15 Mar 2026 15:50:19 -0400 Subject: [PATCH] fix(automation): evaluate staleness before checking protected labels (#22561) --- .../workflows/gemini-scheduled-stale-pr-closer.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gemini-scheduled-stale-pr-closer.yml b/.github/workflows/gemini-scheduled-stale-pr-closer.yml index 87c60b11f8..cc33848941 100644 --- a/.github/workflows/gemini-scheduled-stale-pr-closer.yml +++ b/.github/workflows/gemini-scheduled-stale-pr-closer.yml @@ -200,9 +200,7 @@ jobs: // 4. Staleness Check (Scheduled only) if (pr.state === 'open' && context.eventName !== 'pull_request') { - // PRs with help wanted/maintainer only labels are still checked for staleness - // but usually given more leeway. Here we stick to 30 days of no maintainer activity. - + // Skip PRs that were created less than 30 days ago - they cannot be stale yet const prCreatedAt = new Date(pr.created_at); if (prCreatedAt > thirtyDaysAgo) continue; @@ -229,7 +227,14 @@ jobs: } catch (e) {} if (lastActivity < thirtyDaysAgo) { - core.info(`PR #${pr.number} is stale.`); + const labels = pr.labels.map(l => l.name.toLowerCase()); + const isProtected = labels.includes('help wanted') || labels.includes('🔒 maintainer only'); + if (isProtected) { + core.info(`PR #${pr.number} is stale but has a protected label. Skipping closure.`); + continue; + } + + core.info(`PR #${pr.number} is stale (no maintainer activity for 30+ days). Closing.`); if (!dryRun) { await github.rest.issues.createComment({ owner: context.repo.owner,