Skip to content

Commit

Permalink
add workflow to check image size
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienRichez committed Sep 27, 2023
1 parent ed8d983 commit 3b37908
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/check-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: check-image-size
on:
- pull_request
jobs:
check-image-size:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- shell: bash
run: |
files=$(git diff --name-only origin/${{ github.base_ref }} | grep -E '.+\.png$' | xargs du -h --threshold=1M | cut -f2)
for file in $files; do
echo "::warning title=Big image,file=$file::This image is bigger than 1MB. Consider reducing its pixel size to match the actual size on the website, or use pngcrush or similar to maximize the compression"
done
if ! [[ -z "$files" ]]; then
exit 1
fi

0 comments on commit 3b37908

Please sign in to comment.