-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathcheck-executable-permissions.yml
More file actions
56 lines (47 loc) · 1.85 KB
/
check-executable-permissions.yml
File metadata and controls
56 lines (47 loc) · 1.85 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Enforce Script Executable Permissions
on:
pull_request:
branches: [ "main" ]
paths:
- '**/run.sh'
- '**/*.sh'
push:
branches: [ "main" ]
paths:
- '**/run.sh'
- '**/*.sh'
workflow_dispatch:
jobs:
permissions:
name: Check script permissions
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check for missing +x on shell scripts
run: |
echo "🔍 Checking shell script permissions..."
BAD=$(find . -type f \( -name "*.sh" -o -name "run.sh" \) ! -perm -u=x)
if [ -n "$BAD" ]; then
echo "::error file=run.sh,line=1::❌ Some shell scripts are missing executable permissions. CI and LAVA may break."
echo "::error file=run.sh,line=2::To fix: find . -name '*.sh' -o -name 'run.sh' | xargs chmod +x && git add . && git commit -m 'Fix: restore executable bits' && git push"
echo ""
echo "The following files need 'chmod +x':"
echo "$BAD"
echo "$BAD" | while read -r file; do
echo "::error file=$file,line=1::$file is not executable. Run: chmod +x \"$file\" && git add \"$file\""
done
exit 1
else
echo "✅ All shell scripts have executable permissions."
fi
- name: Warn about non-shell files marked executable (optional)
run: |
echo "🔍 Checking for accidental executables on non-shell files..."
OTHER_EXEC=$(find . -type f ! \( -name "*.sh" -o -name "run.sh" \) -perm -u=x)
if [ -n "$OTHER_EXEC" ]; then
echo "::warning file=run.sh,line=1::⚠️ Some non-shell files have executable bits. Review if appropriate."
echo "$OTHER_EXEC"
else
echo "✅ No unexpected executables detected."
fi