From 2c31ba88fa812bc653526fbb87a8f320d9d6cbfe Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 17 Jul 2024 11:45:03 +0200 Subject: [PATCH] own --- .github/workflows/repo_check.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/repo_check.yml b/.github/workflows/repo_check.yml index 4adcb8e09b678..12d2a9081f116 100644 --- a/.github/workflows/repo_check.yml +++ b/.github/workflows/repo_check.yml @@ -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