summaryrefslogtreecommitdiff
path: root/.github/workflows/scripts/check-size.sh
blob: 15027bd52ab93a134f4951f583b0416eb2b592bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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