mirror of
https://github.com/RetroDECK/Cooker.git
synced 2024-11-21 21:05:37 +00:00
Update delete-old-releases.yml
This commit is contained in:
parent
a7c69c4e60
commit
b1a5336328
16
.github/workflows/delete-old-releases.yml
vendored
16
.github/workflows/delete-old-releases.yml
vendored
|
@ -23,12 +23,18 @@ jobs:
|
||||||
# Define the threshold date (1 month ago)
|
# Define the threshold date (1 month ago)
|
||||||
THRESHOLD_DATE=$(date -d "1 month ago" +%Y-%m-%dT%H:%M:%SZ)
|
THRESHOLD_DATE=$(date -d "1 month ago" +%Y-%m-%dT%H:%M:%SZ)
|
||||||
|
|
||||||
# Get releases older than 1 month
|
# Get all releases (handle pagination)
|
||||||
OLD_RELEASES=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" | jq --arg threshold "$THRESHOLD_DATE" '.[] | select(.published_at < $threshold) | .id')
|
ALL_RELEASES=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases?per_page=100&page=1")
|
||||||
|
PAGE_COUNT=$(echo "$ALL_RELEASES" | jq '. | length')
|
||||||
|
|
||||||
# Delete old releases
|
# Loop through pages and get releases older than 1 month
|
||||||
for release_id in $OLD_RELEASES; do
|
for ((i=0; i<$PAGE_COUNT; i++)); do
|
||||||
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id"
|
OLD_RELEASES=$(echo "$ALL_RELEASES" | jq --arg threshold "$THRESHOLD_DATE" ".[$i] | select(.published_at < \$threshold) | .id")
|
||||||
|
|
||||||
|
# Delete old releases
|
||||||
|
for release_id in $OLD_RELEASES; do
|
||||||
|
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
Loading…
Reference in a new issue