diff --git a/.github/workflows/repo_check.yml b/.github/workflows/repo_check.yml index 4adcb8e09b678..48719c6978756 100644 --- a/.github/workflows/repo_check.yml +++ b/.github/workflows/repo_check.yml @@ -31,8 +31,28 @@ 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 path; do + size="$(git cat-file -s "${id}")" + if [ ${size} > ${MAX_FILE_SIZE_BYTES} ]; then + exit_code=1 + echo "Object ${id} [${path}] has size ${size}, exceeding ${MAX_FILE_SIZE_BYTES} limit." >&2 + echo "::error::File ${path} has size ${size}, exceeding ${MAX_FILE_SIZE_BYTES} limit." + echo "::error file=${path}::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