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 3c0104a commit 3e002a6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 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: Close and mark stale issues, and draft PRs

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

permissions:
contents: read
Expand Down Expand Up @@ -32,3 +33,23 @@ jobs:
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 3e002a6

Please sign in to comment.