From a7c69c4e604b0805f55a6dee2ecc7281bfcbc9da Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 2 Jan 2024 13:39:13 +0100 Subject: [PATCH] Update delete-old-releases.yml --- .github/workflows/delete-old-releases.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/delete-old-releases.yml b/.github/workflows/delete-old-releases.yml index 6f9abb2..78e278d 100644 --- a/.github/workflows/delete-old-releases.yml +++ b/.github/workflows/delete-old-releases.yml @@ -22,13 +22,14 @@ jobs: run: | # Define the threshold date (1 month ago) THRESHOLD_DATE=$(date -d "1 month ago" +%Y-%m-%dT%H:%M:%SZ) - + # Get releases older than 1 month - OLD_RELEASES=$(jq --arg threshold "$THRESHOLD_DATE" '. | select(.published_at < $threshold) | .id' <<< "$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/$GITHUB_REPOSITORY/releases)") - + 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') + # Delete old releases for release_id in $OLD_RELEASES; do - curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id" + curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id" done + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}