Modify stale PR workflow for labeled events
This commit is contained in:
parent
0a446423c6
commit
28cfa9ccd2
24
.github/workflows/stale_pr_close.yml
generated
vendored
24
.github/workflows/stale_pr_close.yml
generated
vendored
@ -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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user