mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-09-22 10:35:40 +00:00
ci: fix nightly prune not working
This change makes it so we keep the last three nightly runs + prune anything that was created today. Tested by just running it manually.
This commit is contained in:
@@ -92,17 +92,29 @@ jobs:
|
|||||||
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
|
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
|
||||||
echo "$RELEASE_NAME"
|
echo "$RELEASE_NAME"
|
||||||
|
|
||||||
# Delete tags older than 3 days, as well as nightly runs that are a duplicate of today.
|
# Delete all but last three nightly runs, as well as nightly runs that are a duplicate of today.
|
||||||
- name: Delete old tags and release if not mock
|
- name: Delete old tags and release if not mock
|
||||||
if: github.event.inputs.isMock != 'true'
|
if: github.event.inputs.isMock != 'true'
|
||||||
run: |
|
run: |
|
||||||
THREE_DAYS_AGO=$(date +%s --date='3 days ago')
|
echo "Deleting any nightly runs with the same name as today's nightly run..."
|
||||||
while true; do
|
while true; do
|
||||||
PREV_NIGHTLY=$(gh release list --json name,tagName,publishedAt | jq --arg THREE_DAYS_AGO "$THREE_DAYS_AGO" --arg RELEASE_NAME "$RELEASE_NAME" -c '[.[] | select (.tagName | contains("nightly-")) | select ((.publishedAt | fromdateiso8601 > $THREE_DAYS_AGO) or (.name == $RELEASE_NAME))][0] | .tagName' | tr -d '"')
|
TO_DELETE_NIGHTLY=$(gh release list --json name,tagName,publishedAt | jq --arg RELEASE_NAME "$RELEASE_NAME" -c '[.[] | select (.tagName | contains("nightly-")) | select (.name == $RELEASE_NAME)][0] | .tagName' | tr -d '"')
|
||||||
|
if [[ "$TO_DELETE_NIGHTLY" != "null" && "$TO_DELETE_NIGHTLY" == *"nightly-"* ]]; then
|
||||||
|
echo "Will delete nightly release with tag '$TO_DELETE_NIGHTLY'";
|
||||||
|
gh release delete $TO_DELETE_NIGHTLY --cleanup-tag || { echo "couldn't delete previous nightly release, halting"; break; }
|
||||||
|
else
|
||||||
|
echo "no nightly releases left, done";
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [[ "$PREV_NIGHTLY" != "null" && "$PREV_NIGHTLY" == *"nightly-"* ]]; then
|
echo "Now pruning all but the last three nightly runs..."
|
||||||
echo "Will delete nightly release with tag '$PREV_NIGHTLY'";
|
while true; do
|
||||||
gh release delete $PREV_NIGHTLY --cleanup-tag || { echo "couldn't delete previous nightly release, halting"; break; }
|
# Very gross trick - keep deleting the 4th nightly element ([3]) until null.
|
||||||
|
TO_DELETE_NIGHTLY=$(gh release list --json name,tagName,publishedAt | jq --arg RELEASE_NAME "$RELEASE_NAME" -c '[.[] | select (.tagName | contains("nightly-"))][4] | .tagName' | tr -d '"')
|
||||||
|
if [[ "$TO_DELETE_NIGHTLY" != "null" && "$TO_DELETE_NIGHTLY" == *"nightly-"* ]]; then
|
||||||
|
echo "Will delete nightly release with tag '$TO_DELETE_NIGHTLY'";
|
||||||
|
gh release delete $TO_DELETE_NIGHTLY --cleanup-tag || { echo "couldn't delete previous nightly release, halting"; break; }
|
||||||
else
|
else
|
||||||
echo "no nightly releases left, done";
|
echo "no nightly releases left, done";
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user