From 3b37908f214689da6f89f012a0e98de1052204a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Richez?= Date: Wed, 27 Sep 2023 09:18:59 +0200 Subject: [PATCH] add workflow to check image size --- .github/workflows/check-images.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/check-images.yaml diff --git a/.github/workflows/check-images.yaml b/.github/workflows/check-images.yaml new file mode 100644 index 0000000..fb1329b --- /dev/null +++ b/.github/workflows/check-images.yaml @@ -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