From 77ea66c382ee7493935a67f0620cf48e9a2b656b Mon Sep 17 00:00:00 2001 From: chaodu-agent Date: Sat, 18 Apr 2026 16:51:53 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20add=20stale=20pending-contributor=20?= =?UTF-8?q?=E2=86=92=20closing-soon=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/stale-contributor.yml | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/stale-contributor.yml diff --git a/.github/workflows/stale-contributor.yml b/.github/workflows/stale-contributor.yml new file mode 100644 index 0000000..4ecc19c --- /dev/null +++ b/.github/workflows/stale-contributor.yml @@ -0,0 +1,56 @@ +name: Label stale pending-contributor PRs + +on: + schedule: + - cron: '0 * * * *' # hourly + workflow_dispatch: + +jobs: + check-stale: + runs-on: ubuntu-latest + permissions: + pull-requests: write + issues: write + steps: + - uses: actions/github-script@v7 + with: + script: | + const CONTRIBUTOR = 'pending-contributor'; + const CLOSING = 'closing-soon'; + const STALE_DAYS = 2; + const cutoff = new Date(Date.now() - STALE_DAYS * 24 * 60 * 60 * 1000); + + const prs = await github.rest.pulls.list({ + ...context.repo, + state: 'open', + per_page: 100 + }); + + for (const pr of prs.data) { + const labels = pr.labels.map(l => l.name); + if (!labels.includes(CONTRIBUTOR)) continue; + if (labels.includes(CLOSING)) continue; + + // Find when pending-contributor was last applied + const { data: events } = await github.rest.issues.listEvents({ + ...context.repo, + issue_number: pr.number, + per_page: 100 + }); + + const labelEvent = events + .filter(e => e.event === 'labeled' && e.label?.name === CONTRIBUTOR) + .pop(); + + if (!labelEvent) continue; + + const labeledAt = new Date(labelEvent.created_at); + if (labeledAt > cutoff) continue; + + await github.rest.issues.addLabels({ + ...context.repo, + issue_number: pr.number, + labels: [CLOSING] + }); + console.log(`#${pr.number} — ${CONTRIBUTOR} since ${labeledAt.toISOString()}, added ${CLOSING}`); + }