summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Leontiev <prohormitrich53@gmail.com>2021-03-21 22:16:01 +0300
committerGitHub <noreply@github.com>2021-03-21 15:16:01 -0400
commita5605d6c46c08ecda49fe545e2d7bff963466284 (patch)
treed2b8e645d43246c90b010380614210e51e7a6c1b
parentbd926ebbc1f7686a1704bcf4acb72fe1bae30075 (diff)
downloadbased.cooking-a5605d6c46c08ecda49fe545e2d7bff963466284.tar
based.cooking-a5605d6c46c08ecda49fe545e2d7bff963466284.tar.gz
based.cooking-a5605d6c46c08ecda49fe545e2d7bff963466284.tar.lz
based.cooking-a5605d6c46c08ecda49fe545e2d7bff963466284.tar.xz
based.cooking-a5605d6c46c08ecda49fe545e2d7bff963466284.zip
Add images size checking in PR (#281)
* Add images size checking in PR * Fix typo * Switched to POSIX shell * More proper diff
-rw-r--r--.github/workflows/pr.yaml12
-rwxr-xr-x.github/workflows/scripts/check-size.sh25
2 files changed, 37 insertions, 0 deletions
diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml
new file mode 100644
index 000000000..756bd07c1
--- /dev/null
+++ b/.github/workflows/pr.yaml
@@ -0,0 +1,12 @@
+on: pull_request
+
+jobs:
+ check_size:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - name: Check file size
+ run: .github/workflows/scripts/check-size.sh
+
diff --git a/.github/workflows/scripts/check-size.sh b/.github/workflows/scripts/check-size.sh
new file mode 100755
index 000000000..15027bd52
--- /dev/null
+++ b/.github/workflows/scripts/check-size.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -eu
+
+SIZE_LIMIT=150000
+
+check_size() {
+ local size=$(stat --printf="%s" $1)
+ if [ "$size" -gt "$SIZE_LIMIT" ]; then
+ echo "File $1 is bigger than specified $SIZE_LIMIT limit"
+ exit 1
+ fi
+}
+
+git diff --name-only `git merge-base origin/master HEAD` | while IFS= read -r file; do
+ case "$file" in
+ *.webp)
+ echo "Checking size of $file"
+ check_size $file
+ ;;
+ *)
+ echo "Skipping $file"
+ ;;
+ esac
+done
+