Skip to content

Commit

Permalink
ci: automate stale labeling for inactive draft PRs
Browse files Browse the repository at this point in the history
ci: automate stale labeling for inactive draft PRs
  • Loading branch information
rjan90 committed Jan 27, 2025
1 parent a90ee17 commit de3858d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Close and mark stale issue
name: Mark and close stale items

on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:

permissions:
contents: read
Expand All @@ -28,5 +29,27 @@ jobs:
days-before-issue-close: 3
days-before-pr-stale: 5
days-before-pr-close: 3
draft-days-before-stale: 1050 # 35 months * 30 days
draft-days-before-close: -1 # Don't automatically close draft PRs
remove-stale-when-updated: true
enable-statistics: true

mark-stale-draft-prs:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Mark stale draft PRs
env:
GH_TOKEN: ${{ github.token }}
run: |
# Calculate cutoff date for last update (365 days ago)
cutoff_date=$(date -d "365 days ago" +%Y-%m-%d)
prs=$(gh pr list --repo $GITHUB_REPOSITORY --state open \
--json number,updatedAt,isDraft \
--jq ".[] | select(.isDraft) | select(.updatedAt < \"$cutoff_date\") | .number")
for pr in $prs; do
echo "Marking PR #$pr as stale"
gh pr edit $pr --add-label "kind/stale"
done

0 comments on commit de3858d

Please sign in to comment.