mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-25 04:15:45 -08:00
CI: Prevent large files from being added
This commit is contained in:
33
.github/workflows/file-size.yml
vendored
Normal file
33
.github/workflows/file-size.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: File Size Check
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v18.4
|
||||
- name: List all changed files
|
||||
run: |
|
||||
# MAXSIZE is 1 MB
|
||||
MAXSIZE=1000000
|
||||
for FILENAME in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||
FILESIZE=$(stat -c%s "$FILENAME")
|
||||
echo "Size of $FILENAME = $FILESIZE bytes."
|
||||
if (( FILESIZE > MAXSIZE)); then
|
||||
echo "$FILENAME is too big. Only $MAXSIZE bytes allowed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user