Skip to content

Commit

Permalink
lock-prs: Add finer permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
bbhtt committed Dec 10, 2024
1 parent 73b4e7d commit 9f7c5f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/lock-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ on:

jobs:
lock:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Lock closed PRs
run: |
pr_list=$(gh pr list -L 100000 --state closed --json number,updatedAt)
recent_prs=$(echo "$pr_list" | jq '[.[] | select(.updatedAt >= (now - (7 * 24 * 60 * 60) | todate))]')
sorted_prs=$(echo "$recent_prs" | jq 'sort_by(.updatedAt) | .[] | {number: .number, updatedAt: .updatedAt}')
cmd=$(echo "$sorted_prs" | jq '.number' | head -n 100)
list=$(echo "$sorted_prs" | jq '.number' | head -n 100)
for num in $cmd; do
unset pr_list recent_prs sorted_prs
for num in $list; do
if [ "$(gh api repos/"$GH_REPO"/issues/"$num" --jq '.locked')" = "false" ]; then
if ! gh pr view --json labels -q '.labels[].name' "$num"|grep -qE "^(Stale|leave-open)$"; then
echo "Locking pull request $num"
Expand Down

0 comments on commit 9f7c5f1

Please sign in to comment.