From 28cfa9ccd268af0af54c86c5a3a05608a9b2ef71 Mon Sep 17 00:00:00 2001 From: Tobias <96661824+CrazyWolf13@users.noreply.github.com> Date: Sun, 8 Feb 2026 21:17:26 +0100 Subject: [PATCH] Modify stale PR workflow for labeled events --- .github/workflows/stale_pr_close.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stale_pr_close.yml b/.github/workflows/stale_pr_close.yml index 6b0531936..e16a66afa 100644 --- a/.github/workflows/stale_pr_close.yml +++ b/.github/workflows/stale_pr_close.yml @@ -1,8 +1,11 @@ name: Stale PR Management on: schedule: - - cron: "0 0 * * *" # Daily at midnight UTC - workflow_dispatch: # Allow manual trigger for testing + - cron: "0 0 * * *" + workflow_dispatch: + pull_request_target: # Changed from pull_request + types: + - labeled jobs: stale-prs: @@ -12,7 +15,7 @@ jobs: issues: write contents: read steps: - - name: Handle stale PRs + - name: Handle stale label uses: actions/github-script@v7 with: script: | @@ -20,6 +23,21 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; + // --- PR labeled event --- + if (context.eventName === "pull_request_target" && context.payload.action === "labeled") { + const label = context.payload.label?.name; + if (label === "stale") { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: context.payload.pull_request.number, + body: "This PR has been marked as stale. It will be closed if no new commits are added in 7 days." + }); + } + return; + } + + // --- Scheduled run --- const { data: prs } = await github.rest.pulls.list({ owner, repo,