reduce log spam

This commit is contained in:
boubou19 2025-07-24 11:43:34 +02:00
parent 12170bde1f
commit ff781d6503

View File

@ -16,8 +16,36 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y optipng run: sudo apt-get update && sudo apt-get install -y optipng
- name: Optimize PNG files - name: Optimize PNG files
id: optimize_png
run: | run: |
find . -type f -name "*.png" ! -path "./.git/*" -exec optipng -o7 -nc {} + set -euo pipefail
FAILED_FILES=""
while IFS= read -r -d '' file; do
echo "Compressing: $file"
if ! optipng -o7 -nc "$file" >/dev/null 2>&1; then
STATUS=$?
if [[ $STATUS -gt 2 ]]; then
echo "FAILED: $file (exit code $STATUS)"
FAILED_FILES+="$file"$'\n'
else
echo "Skipped (already optimized or warning): $file"
fi
fi
done < <(find . -type f -name "*.png" ! -path "./.git/*" -print0)
if [[ -n "$FAILED_FILES" ]]; then
echo "failed_files<<EOF" >> "$GITHUB_OUTPUT"
echo "$FAILED_FILES" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
exit 1
fi
- name: Print files that failed to compress
if: failure() && steps.optimize_png.outputs.failed_files != ''
run: |
echo "The following files failed to compress:"
echo "${{ steps.optimize_png.outputs.failed_files }}"
- name: Check for changes - name: Check for changes
id: check_changes id: check_changes
@ -28,7 +56,6 @@ jobs:
echo "needs_compression=false" >> "$GITHUB_OUTPUT" echo "needs_compression=false" >> "$GITHUB_OUTPUT"
fi fi
- name: Create Pull Request if Needed - name: Create Pull Request if Needed
if: ${{ steps.check_changes.outputs.needs_compression == 'true' && github.event_name == 'pull_request' && !github.event.pull_request.draft }} if: ${{ steps.check_changes.outputs.needs_compression == 'true' && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
run: | run: |