diff --git a/.github/workflows/clean-up-unused-images.yaml b/.github/workflows/clean-up-unused-images.yaml index 3b031244eaa..50e45309367 100644 --- a/.github/workflows/clean-up-unused-images.yaml +++ b/.github/workflows/clean-up-unused-images.yaml @@ -5,6 +5,8 @@ on: # On the first of every month at 2 am - cron: '0 2 1 * *' workflow_dispatch: + push: + branches: ['handle-zero-images-doc-1232'] concurrency: group: clean-up-images-${{ github.ref }} @@ -49,10 +51,16 @@ jobs: - name: Create PR with unused images run: | - unused_image_count=$(wc -l < unused_images.json) - if unused_image_count == 0; then - "No images found to remove." - exit 0 + file="unused_images.json" + if [[ -f "$file" ]]; then + unused_image_count=$(wc -l < "$file") + if $unused_image_count == 0; then + "No images found to remove." + exit 0 + fi + else + echo "File $file not found." + exit 1 fi # Ensure that we are on master.