forked from community-scripts/ProxmoxVE
-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (36 loc) · 1.27 KB
/
check-lowercase.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
32
33
34
35
36
37
38
39
40
41
42
43
name: Check Lowercase Filenames
on:
pull_request:
paths:
- 'ct/**'
- 'install/**'
jobs:
check_lowercase:
runs-on: lxc
steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Validate filenames are lowercase
- name: Validate filenames are lowercase
run: |
# Get the list of changed files
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^(ct|install)/')
ERROR_COUNT=0
# Process each file safely using newline as delimiter
echo "$changed_files" | while IFS= read -r FILE; do
BASENAME=$(basename "$FILE")
if [[ "$BASENAME" =~ ^[a-z0-9._-]+$ ]]; then
echo "$FILE: Check for lowercase in filename passed."
else
echo "Error in $FILE. Change filename to lowercase."
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
done
# Fail the workflow if any errors are found
if [ "$ERROR_COUNT" -ne 0 ]; then
echo "$ERROR_COUNT script(s) have invalid filenames."
exit 1
else
echo "All filenames passed the lowercase check."
fi