File tree Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change 1
1
name : Shell Lint
2
2
3
3
on :
4
- pull_request_target :
4
+ pull_request :
5
5
branches : [ "main" ]
6
6
push :
7
7
branches : [ "main" ]
10
10
jobs :
11
11
shellcheck :
12
12
runs-on : ubuntu-latest
13
+
13
14
steps :
14
- - uses : actions/checkout@v3
15
- - name : Install ShellCheck 0.9.0-1
16
- run : sudo apt-get install -y shellcheck=0.9.0-1
17
- - name : Run ShellCheck with exclusions
15
+ - name : Checkout source
16
+ uses : actions/checkout@v3
17
+
18
+ - name : Install ShellCheck from apt
19
+ run : |
20
+ sudo apt-get update
21
+ sudo apt-get install -y shellcheck=0.9.0-1
22
+
23
+ - name : Run ShellCheck on changed .sh files in PR
24
+ if : github.event_name == 'pull_request'
25
+ run : |
26
+ echo "Checking only changed shell files in PR..."
27
+ git fetch origin ${{ github.base_ref }}
28
+ FILES=$(git diff --name-only origin/${{ github.base_ref }} -- '*.sh' | xargs -r -n1 echo | xargs -r realpath --no-symlinks --canonicalize-missing 2>/dev/null || true)
29
+ if [ -n "$FILES" ]; then
30
+ echo "$FILES" | tr ' ' '\n' | xargs -r shellcheck -S warning -e SC1091,SC2230,SC3043
31
+ else
32
+ echo "No shell files to lint."
33
+ fi
34
+
35
+ - name : Run ShellCheck on all .sh files (main or manual trigger)
36
+ if : github.event_name != 'pull_request'
18
37
run : |
19
- find . -name '*.sh' -print0 | xargs -0 shellcheck -S warning -e SC1091,SC2230,SC3043
38
+ echo "Linting all shell files in repository..."
39
+ find . -type f -name '*.sh' -print0 | xargs -0 -r shellcheck -S warning -e SC1091,SC2230,SC3043
You can’t perform that action at this time.
0 commit comments