diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6b601f52a56..64455355e4c 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -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 @@ -30,3 +31,22 @@ jobs: days-before-pr-close: 3 remove-stale-when-updated: true enable-statistics: true + label-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 \ No newline at end of file