-
Notifications
You must be signed in to change notification settings - Fork 634
31 lines (30 loc) · 1.24 KB
/
check_file_size.yml
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
name: Check file size
on: pull_request
jobs:
check_file_size:
name: Check file size
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed files
id: get_changed_files
uses: tj-actions/changed-files@v45
with:
write_output_files: true
- name: List changed files
run: |
echo "# Changed Files" >> $GITHUB_STEP_SUMMARY
echo "Files changed - ${{ steps.get_changed_files.outputs.all_changed_files_count }}" >> $GITHUB_STEP_SUMMARY
echo "| File | Size | Check |" >> $GITHUB_STEP_SUMMARY
echo "| :-- | :-- | :-- |" >> $GITHUB_STEP_SUMMARY
for file in $(cat .github/outputs/all_changed_files.txt); do
size=$(ls -lh ${file} | awk '{print $5}')
check=$([[ -n $(find "${file}" -type f -size +50M) ]] && echo "❌" || echo "✅")
echo "| ${file} | ${size} | ${check} |" >> $GITHUB_STEP_SUMMARY
done
- name: Check file size
run: |
for file in $(cat .github/outputs/all_changed_files.txt); do
[[ -n $(find "${file}" -type f -size +50M) ]] && { echo "❌ $file exceeds file size limit"; exit 1; } || echo "✅ $file"
done