Skip to content

Commit

Permalink
own
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Jul 17, 2024
1 parent eb7c2f0 commit 2c31ba8
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/repo_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,31 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: james-callahan/gha-prevent-big-files@5bff33da9b9970f671495034b0f7255619b1b8e0
with:
# 1 MB in bytes. 1 MB ought to be enough for anybody.
- name: Check sizes of new Git objects
env:
# 1 MB ought to be enough for anybody.
# TODO in case we may want to consciously commit a bigger file to the repo we may disable the check e.g. with a label
max-size: 1048576
MAX_FILE_SIZE_BYTES: 1048576
shell: bash
run: |
git rev-list --objects ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
> new-pr-objects.txt
exit_code=0
while read -r id name; do
size="$(git cat-file -s "${id}")"
if [ "${size}" -gt "${MAX_FILE_SIZE_BYTES}" ]; then
exit_code=1
if [ -z "${name}" ]; then
name="$(git cat-file -t "${id}") ${id}"
fi
echo "Object ${id} [${name}] has size ${size}, exceeding ${MAX_FILE_SIZE_BYTES} limit." >&2
echo "::error::File ${name} has size ${size}, exceeding ${MAX_FILE_SIZE_BYTES} limit."
echo "::error file=${name}::This file has size ${size}, exceeding ${MAX_FILE_SIZE_BYTES} limit."
fi
done < new-pr-objects.txt
exit "${exit_code}"
# - uses: james-callahan/gha-prevent-big-files@5bff33da9b9970f671495034b0f7255619b1b8e0
# with:
# # 1 MB in bytes. 1 MB ought to be enough for anybody.
# # TODO in case we may want to consciously commit a bigger file to the repo we may disable the check e.g. with a label
# max-size: 1048576

0 comments on commit 2c31ba8

Please sign in to comment.