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

A size checker action which checks for files > 100KB. #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions .github/workflows/size_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Enforce 100KB size limit
on:
pull_request
jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
# Check only files modified by this change to see if any exceed 100K
- name: Size check
run: |
changed=$(git diff --name-only -r HEAD^1 HEAD)
if [[ -z $changed ]]; then exit 0; fi
big=$(find $changed -size +50k -size -100k)
if [[ -n $big ]]; then for file in $big; do echo "::warning file=${file},title=Large file::This file is >50KB, consider shrinking it if possible."; done; fi
too_large=$(find $changed -size +100k)
if [[ -n $too_large ]]; then for file in $too_large; do echo "::error file=${file},title=File too large::This file is >100KB and must be shrunk prior to being comitted."; done; exit 1; fi