Skip to content

Commit

Permalink
For nightly-cleanup, only preserve last two months
Browse files Browse the repository at this point in the history
Fix typo in run command, that lead to a failure.
  • Loading branch information
qu1queee committed Sep 6, 2023
1 parent c79ec2e commit 0d3e2e4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/cleanup-nightly-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ jobs:
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- name: Get previous month
id: previousmonth
run: echo "date=$(date -d "1 month ago" +%Y-%m')" >> $GITHUB_OUTPUT
- name: Get two months ago
id: twomonthsago
run: echo "date=$(date -d "2 month ago" +%Y-%m)" >> $GITHUB_OUTPUT
run: echo "date=$(date -d "1 month ago" +%Y-%m)" >> $GITHUB_OUTPUT
- name: Generate and upload release YAMLs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -33,13 +30,13 @@ jobs:
ASSETS_TOTAL=$(ls $WORK_DIR | wc -l)
echo "[INFO] Currently ${ASSETS_TOTAL} assets for nightly release"
ASSETS_TO_REMOVE=$(ls $WORK_DIR | grep -v "${{ steps.currentmonth.outputs.date }}\|${{ steps.previousmonth.outputs.date }}\|${{ steps.twomonthsago.outputs.date }}" | wc -l)
ASSETS_TO_REMOVE=$(ls $WORK_DIR | grep -v "${{ steps.currentmonth.outputs.date }}\|${{ steps.previousmonth.outputs.date }}" | wc -l)
if [ "$ASSETS_TO_REMOVE" -eq "0" ]; then
echo "[INFO] Nothing to delete"
exit 0
fi
find $WORK_DIR -type f -iname "*.yaml" -printf "%f\n" | grep -v "${{ steps.currentmonth.outputs.date }}\|${{ steps.previousmonth.outputs.date }}\|${{ steps.twomonthsago.outputs.date }}" |
find $WORK_DIR -type f -iname "*.yaml" -printf "%f\n" | grep -v "${{ steps.currentmonth.outputs.date }}\|${{ steps.previousmonth.outputs.date }}" |
while IFS= read FILE; do
gh release delete-asset nightly $FILE -y
done
Expand Down

0 comments on commit 0d3e2e4

Please sign in to comment.