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
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,