You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- '**/*.sh'# Führt den Check nur für Shell-Skripte aus
7
+
8
+
jobs:
9
+
check-scripts:
10
+
runs-on: ubuntu-latest
11
+
12
+
steps:
13
+
- name: Checkout Code
14
+
uses: actions/checkout@v3
15
+
16
+
- name: Check `source` Line in Scripts
17
+
shell: bash
18
+
run: |
19
+
set -e
20
+
ERROR_COUNT=0
21
+
FILES=$(find . -name "*.sh")
22
+
23
+
for FILE in $FILES; do
24
+
# Check for exact match of the source line in line 2
25
+
if [[ $(sed -n '2p' "$FILE") =~ ^source[[:space:]]+<(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) ]]; then
26
+
echo "Check passed for: $FILE"
27
+
else
28
+
echo "Error in $FILE: Line 2 must be exactly 'source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)' if a source line is used."
29
+
ERROR_COUNT=$((ERROR_COUNT + 1))
30
+
fi
31
+
32
+
# Check for shebang line at the top
33
+
if [[ $(head -n 1 "$FILE") != "#!/usr/bin/env bash" ]]; then
34
+
echo "Error in $FILE: The first line must be '#!/usr/bin/env bash'."
35
+
ERROR_COUNT=$((ERROR_COUNT + 1))
36
+
fi
37
+
38
+
# Check for executable permissions
39
+
if [[ ! -x "$FILE" ]]; then
40
+
echo "Warning in $FILE: This script is not executable. Consider running 'chmod +x $FILE'."
41
+
fi
42
+
43
+
# Check for empty lines at the beginning of the script
44
+
if [[ $(head -n 10 "$FILE" | grep -c '^$') -gt 0 ]]; then
45
+
echo "Warning in $FILE: There are empty lines at the beginning of the script. Consider removing them."
0 commit comments