Orion Weller
commited on
Create check_file_sizes.yml
Browse files
.github/workflows/check_file_sizes.yml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Check File Sizes
|
2 |
+
|
3 |
+
on:
|
4 |
+
pull_request:
|
5 |
+
branches: [ main ]
|
6 |
+
|
7 |
+
jobs:
|
8 |
+
check-file-size:
|
9 |
+
runs-on: ubuntu-latest
|
10 |
+
steps:
|
11 |
+
- uses: actions/checkout@v2
|
12 |
+
with:
|
13 |
+
fetch-depth: 0 # This ensures we get the full history
|
14 |
+
|
15 |
+
- name: Check file sizes
|
16 |
+
run: |
|
17 |
+
MAX_SIZE_BYTES=$((10 * 1024 * 1024)) # 10MB in bytes
|
18 |
+
|
19 |
+
# Get list of files changed in this PR
|
20 |
+
FILES_CHANGED=$(git diff --name-only --diff-filter=d ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
|
21 |
+
|
22 |
+
# Check each file
|
23 |
+
for file in $FILES_CHANGED; do
|
24 |
+
if [ -f "$file" ]; then
|
25 |
+
size=$(stat -c%s "$file")
|
26 |
+
if [ $size -gt $MAX_SIZE_BYTES ]; then
|
27 |
+
echo "Error: $file is larger than 10MB (size: $size bytes)"
|
28 |
+
exit 1
|
29 |
+
fi
|
30 |
+
fi
|
31 |
+
done
|
32 |
+
|
33 |
+
echo "All files are within the size limit."
|