-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (42 loc) · 1.37 KB
/
Copy pathshellcheck.yml
File metadata and controls
48 lines (42 loc) · 1.37 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
name: Shell Lint
permissions:
contents: read
on:
push:
paths:
- '**.sh'
- '.github/workflows/shellcheck.yml'
pull_request:
paths:
- '**.sh'
- '.github/workflows/shellcheck.yml'
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install ShellCheck
run: sudo apt-get update -y && sudo apt-get install -y shellcheck
- name: Run ShellCheck
run: |
set -euo pipefail
echo "Scanning shell scripts..."
# Find all tracked *.sh files plus executable scripts with bash shebang
SCRIPTS=$(git ls-files '*.sh')
# Optionally include non-.sh executables with bash shebang
while IFS= read -r f; do
if head -1 "$f" | grep -qE '^#!.*bash'; then
SCRIPTS+=$'\n'$f
fi
done < <(git ls-files | grep -v '\.sh$')
# De-duplicate list
echo "$SCRIPTS" | sort -u > /tmp/scripts.list
echo "Files to check:"; cat /tmp/scripts.list
# Run shellcheck (excluding vendor or 3rd-party dirs if any in future)
xargs -a /tmp/scripts.list -r shellcheck --severity=style
- name: Upload SARIF (optional code scanning)
if: false
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif