-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathshell_script_enforce_exec_check.yml
More file actions
42 lines (36 loc) · 1.15 KB
/
shell_script_enforce_exec_check.yml
File metadata and controls
42 lines (36 loc) · 1.15 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
name: shell-script-enforce-exec-check
on:
pull_request:
push:
branches: ['**']
permissions:
contents: read
jobs:
exec-bit:
name: Enforce executable bit on scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Verify shell/python scripts are executable
run: |
set -euo pipefail
echo "Checking tracked .sh files are executable."
echo "This prevents CI/runtime failures when scripts are invoked."
fail=0
while IFS= read -r -d '' file; do
if [[ ! -x "$file" ]]; then
echo "Non-executable .sh: $file"
fail=1
fi
done < <(git ls-files -z '*.sh')
echo "Checking tracked .py files under scripts/ are executable."
while IFS= read -r -d '' file; do
if [[ ! -x "$file" ]]; then
echo "Non-executable scripts/*.py: $file"
fail=1
fi
done < <(git ls-files -z 'scripts/*.py' 'scripts/**/*.py')
if [[ "$fail" -ne 0 ]]; then
echo "Fix with: git update-index --chmod=+x <file>"
exit 1
fi