Skip to content

Commit de3858d

Browse files
committed
ci: automate stale labeling for inactive draft PRs
ci: automate stale labeling for inactive draft PRs
1 parent a90ee17 commit de3858d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/stale.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: Close and mark stale issue
1+
name: Mark and close stale items
22

33
on:
44
schedule:
55
- cron: '0 12 * * *'
6+
workflow_dispatch:
67

78
permissions:
89
contents: read
@@ -28,5 +29,27 @@ jobs:
2829
days-before-issue-close: 3
2930
days-before-pr-stale: 5
3031
days-before-pr-close: 3
32+
draft-days-before-stale: 1050 # 35 months * 30 days
33+
draft-days-before-close: -1 # Don't automatically close draft PRs
3134
remove-stale-when-updated: true
3235
enable-statistics: true
36+
37+
mark-stale-draft-prs:
38+
permissions:
39+
pull-requests: write
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Mark stale draft PRs
43+
env:
44+
GH_TOKEN: ${{ github.token }}
45+
run: |
46+
# Calculate cutoff date for last update (365 days ago)
47+
cutoff_date=$(date -d "365 days ago" +%Y-%m-%d)
48+
prs=$(gh pr list --repo $GITHUB_REPOSITORY --state open \
49+
--json number,updatedAt,isDraft \
50+
--jq ".[] | select(.isDraft) | select(.updatedAt < \"$cutoff_date\") | .number")
51+
52+
for pr in $prs; do
53+
echo "Marking PR #$pr as stale"
54+
gh pr edit $pr --add-label "kind/stale"
55+
done

0 commit comments

Comments
 (0)