Skip to content

Commit ae0b5f8

Browse files
jdxclaude
andcommitted
chore(ci): improve pr-closer workflow
- Add explicit `permissions: pull-requests: write` so the job won't 403 on read-only default tokens. - Replace hardcoded `jdx/mise` with `${{ github.repository }}` (via REPO env). - Filter stale PRs server-side via `--search "updated:<CUTOFF -author:jdx -label:keep-open sort:updated-asc"` and bump `--limit` to 500. Only stale candidates are fetched, sorted oldest-first, and any beyond the limit roll into the next daily run. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 580635a commit ae0b5f8

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

.github/workflows/pr-closer.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ on:
88
jobs:
99
close-stale-prs:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
1113
steps:
1214
- name: Close stale PRs
1315
env:
1416
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
REPO: ${{ github.repository }}
1518
run: |
16-
gh pr list -R jdx/mise --state open --json number,author,labels,updatedAt,statusCheckRollup --limit 100 | \
17-
jq -r '.[] | select(
18-
(.updatedAt | fromdateiso8601) < (now - 30*24*60*60) and
19-
.author.login != "jdx" and
20-
([.labels[].name] | index("keep-open") | not)
21-
) | [.number, (if (.statusCheckRollup | length > 0) and ([.statusCheckRollup[].conclusion] | index("FAILURE") or index("failure")) then "failing" else "passing" end)] | @tsv' | \
19+
CUTOFF=$(date -u -d '30 days ago' +%Y-%m-%d)
20+
gh pr list -R "$REPO" --state open --search "updated:<$CUTOFF -author:jdx -label:keep-open sort:updated-asc" --json number,statusCheckRollup --limit 500 | \
21+
jq -r '.[] | [.number, (if (.statusCheckRollup | length > 0) and ([.statusCheckRollup[].conclusion] | index("FAILURE") or index("failure")) then "failing" else "passing" end)] | @tsv' | \
2222
while read -r pr status; do
2323
echo "Closing PR #$pr (checks: $status)"
2424
if [ "$status" = "failing" ]; then
25-
gh pr close "$pr" -R jdx/mise -c "This PR has been open for more than 30 days without activity. Note: CI checks were failing, which may be why it wasn't reviewed. Feel free to reopen or create a new PR if you'd like to continue working on this."
25+
gh pr close "$pr" -R "$REPO" -c "This PR has been open for more than 30 days without activity. Note: CI checks were failing, which may be why it wasn't reviewed. Feel free to reopen or create a new PR if you'd like to continue working on this."
2626
else
27-
gh pr close "$pr" -R jdx/mise -c "This PR has been open for more than 30 days without activity. Feel free to reopen or create a new PR if you'd like to continue working on this."
27+
gh pr close "$pr" -R "$REPO" -c "This PR has been open for more than 30 days without activity. Feel free to reopen or create a new PR if you'd like to continue working on this."
2828
fi
2929
done

0 commit comments

Comments
 (0)