fix filter
This commit is contained in:
parent
2f61bc994c
commit
3b7740b4cc
21
.github/workflows/clear_old_branches.yml
generated
vendored
21
.github/workflows/clear_old_branches.yml
generated
vendored
@ -32,7 +32,10 @@ jobs:
|
|||||||
--base main \
|
--base main \
|
||||||
--json number,state,mergedAt,closedAt,headRefName \
|
--json number,state,mergedAt,closedAt,headRefName \
|
||||||
--limit 500 |
|
--limit 500 |
|
||||||
jq -r '.[] | select(.state == "MERGED" or .state == "CLOSED") | .headRefName' |
|
jq -r --arg cutoff "$CUTOFF_DATE" '.[] |
|
||||||
|
select(.state == "MERGED" or .state == "CLOSED") |
|
||||||
|
select(((.mergedAt // .closedAt) | fromdateiso8601) < ($cutoff | tonumber)) |
|
||||||
|
.headRefName' |
|
||||||
sort -u |
|
sort -u |
|
||||||
while read -r branch; do
|
while read -r branch; do
|
||||||
# Schutz
|
# Schutz
|
||||||
@ -45,17 +48,11 @@ jobs:
|
|||||||
|
|
||||||
echo "Checking if branch still exists: $branch"
|
echo "Checking if branch still exists: $branch"
|
||||||
if gh api -X GET repos/${{ github.repository }}/git/refs/heads/$branch 2>/dev/null; then
|
if gh api -X GET repos/${{ github.repository }}/git/refs/heads/$branch 2>/dev/null; then
|
||||||
CLOSED_OR_MERGED_TS=$(date -d "$branch" +%s 2>/dev/null || date +%s)
|
echo "Deleting branch: $branch"
|
||||||
|
gh api \
|
||||||
if [ "$CLOSED_OR_MERGED_TS" -lt "$CUTOFF_DATE" ]; then
|
-X DELETE \
|
||||||
echo "Deleting branch: $branch"
|
repos/${{ github.repository }}/git/refs/heads/$branch \
|
||||||
gh api \
|
|| echo "Failed to delete branch $branch"
|
||||||
-X DELETE \
|
|
||||||
repos/${{ github.repository }}/git/refs/heads/$branch \
|
|
||||||
|| echo "Failed to delete branch $branch"
|
|
||||||
else
|
|
||||||
echo "Keeping branch: $branch (recent)"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "Branch $branch does not exist (already deleted)"
|
echo "Branch $branch does not exist (already deleted)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user