Skip to content

Commit

Permalink
ci(workflow): add lint-image-size job
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Sep 25, 2023
1 parent a7a1301 commit c641cee
Showing 1 changed file with 26 additions and 1 deletion.
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" "*.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

0 comments on commit c641cee

Please sign in to comment.