Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(workflow): add lint-image-size job #322

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
if [[ $type =~ ^(WEBP|SVG|ICO)$ ]]; then
echo "✅ $file"
else
>&2 echo "❌ $file incorrect. Please use only webp or svg format 🙏"
>&2 echo "❌ $file incorrect. Please use only webp or svg format. 🙏"
FAILED=1
fi
done
Expand All @@ -94,6 +94,31 @@ jobs:
env:
FOLDER: ./static

lint-image-size:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint image files
run: |
MAX_SIZE=200000
FAILED=0
for file in $(find "$FOLDER" -regextype posix-egrep -regex '.+\.(bmp|ico|jpg|jpeg|png|svg|webp)'); do
size=$(wc -c "$file" | awk '{print $1}')
if [ "$size" -gt "$MAX_SIZE" ]; then
>&2 echo "❌ $file is $size. Please reduce its size to a maximum of $MAX_SIZE. 🙏"
FAILED=1
else
echo "✅ $file"
fi
done
if [ "${FAILED}" = "1" ]; then
exit 1
fi
env:
FOLDER: ./static

report-new-dependencies:
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
Expand Down
Loading