Skip to content

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

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

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

Workflow file for this run

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)
if [[ -n $big ]]; then echo "::warning file=${big},title=Large files::These files are >50KB, consider shrinking them if possible."; fi
too_large=$(find $changed -size +100k)
if [[ -n $too_large ]]; then echo "::error file=$(too_large},title=Files too large::These files are >100KB and must be shrunk prior to being comitted."; fi