13
0
Fork 0
mirror of https://github.com/jdx/mise-action.git synced 2026-06-29 00:00:44 +00:00

chore(ci): use pr-closer action

This commit is contained in:
default 2026-06-04 17:11:14 +00:00
parent 69c24ed920
commit 6e9ac1e446

View file

@ -10,45 +10,12 @@ concurrency:
cancel-in-progress: true
jobs:
close-stale-prs:
pr-closer:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
checks: read
statuses: read
steps:
- name: Close stale PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
set -o pipefail
CUTOFF=$(date -u -d '6 days ago' +%Y-%m-%d)
gh pr list -R "$REPO" --state open --search "updated:<$CUTOFF -author:jdx -label:keep-open draft:false" --json number,mergeStateStatus,statusCheckRollup --limit 500 | \
jq -r '
def failed_check:
(.statusCheckRollup | length > 0) and
([.statusCheckRollup // [] | .[] | ((.conclusion // .state // "") | ascii_upcase)] | any(. == "FAILURE" or . == "ERROR" or . == "TIMED_OUT" or . == "ACTION_REQUIRED"));
.[]
| failed_check as $failed
| ([.statusCheckRollup // [] | .[] | ((.conclusion // .state // "") | ascii_upcase)] | any(. == "CANCELLED")) as $cancelled
| (.mergeStateStatus == "DIRTY") as $conflicted
| (.mergeStateStatus == "UNKNOWN") as $unknown
| if $failed and $conflicted then [.number, "failing checks and merge conflicts"]
elif $failed then [.number, "failing checks"]
elif $conflicted then [.number, "merge conflicts"]
elif $cancelled then [.number, "cancelled checks", "warn"]
elif $unknown then [.number, "unknown merge state", "warn"]
else empty
end
| @tsv
' | \
while IFS=$'\t' read -r pr reason action; do
if [ "$action" = "warn" ]; then
echo "Skipping PR #$pr ($reason)"
continue
fi
echo "Closing PR #$pr ($reason)"
gh pr close "$pr" -R "$REPO" -c "This PR has been inactive for at least 7 days and currently has $reason. Feel free to reopen or create a new PR if you'd like to continue working on this." || echo "Warning: failed to close PR #$pr, skipping"
done
- uses: jdx/pr-closer@v1