Modify stale PR workflow for labeled events

This commit is contained in:
Tobias 2026-02-08 21:17:26 +01:00 committed by GitHub
parent 0a446423c6
commit 28cfa9ccd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

24
.github/workflows/stale_pr_close.yml generated vendored
View File

@ -1,8 +1,11 @@
name: Stale PR Management name: Stale PR Management
on: on:
schedule: schedule:
- cron: "0 0 * * *" # Daily at midnight UTC - cron: "0 0 * * *"
workflow_dispatch: # Allow manual trigger for testing workflow_dispatch:
pull_request_target: # Changed from pull_request
types:
- labeled
jobs: jobs:
stale-prs: stale-prs:
@ -12,7 +15,7 @@ jobs:
issues: write issues: write
contents: read contents: read
steps: steps:
- name: Handle stale PRs - name: Handle stale label
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
@ -20,6 +23,21 @@ jobs:
const owner = context.repo.owner; const owner = context.repo.owner;
const repo = context.repo.repo; 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({ const { data: prs } = await github.rest.pulls.list({
owner, owner,
repo, repo,