-
Notifications
You must be signed in to change notification settings - Fork 18
Action check fille size #75
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||
| name: Check file sizes | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ "main" ] | ||||||
| pull_request: | ||||||
| branches: [ "main" ] | ||||||
|
|
||||||
| jobs: | ||||||
| check: | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Check for images larger than 150KB | ||||||
| run: | | ||||||
| MAX_SIZE="150k" | ||||||
| LARGE_FILES=$(find img -type f -size +$MAX_SIZE) | ||||||
|
||||||
| LARGE_FILES=$(find img -type f -size +$MAX_SIZE) | |
| LARGE_FILES=$(find img -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' \) -size +$MAX_SIZE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
findcommand assumes theimgdirectory exists. If the directory doesn't exist or is empty, the command will fail. Add-dflag or use a path check to handle this gracefully:find . -path ./img -prune -o -path ./img -type f -size +$MAX_SIZE -printor check if the directory exists first with[ -d img ] && ...