Skip to content

Commit

Permalink
Merge pull request #1376 from qu1queee/qu1queee/fix_cleanup_action
Browse files Browse the repository at this point in the history
For nightly-cleanup, only preserve last two months
  • Loading branch information
openshift-merge-robot authored Sep 6, 2023
2 parents 5bb2d76 + 0d3e2e4 commit 97fbc68
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 97fbc68

Please sign in to comment.