-
Notifications
You must be signed in to change notification settings - Fork 17
37 lines (33 loc) · 934 Bytes
/
file-size-check.yaml
File metadata and controls
37 lines (33 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: File Size Check
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
- name: List all changed files
run: |
# MAXSIZE is 10 MB
MAXSIZE=10000000
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