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 11name : Shell Lint
22
33on :
4- pull_request_target :
4+ pull_request :
55 branches : [ "main" ]
66 push :
77 branches : [ "main" ]
1010jobs :
1111 shellcheck :
1212 runs-on : ubuntu-latest
13+
1314 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'
1837 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