mirror of
https://github.com/LukeSmithxyz/based.cooking.git
synced 2024-11-27 16:05:44 +00:00
Add images size checking in PR (#281)
* Add images size checking in PR * Fix typo * Switched to POSIX shell * More proper diff
This commit is contained in:
parent
bd926ebbc1
commit
a5605d6c46
12
.github/workflows/pr.yaml
vendored
Normal file
12
.github/workflows/pr.yaml
vendored
Normal file
@ -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
|
||||
|
25
.github/workflows/scripts/check-size.sh
vendored
Executable file
25
.github/workflows/scripts/check-size.sh
vendored
Executable file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user