-
Notifications
You must be signed in to change notification settings - Fork 33
54 lines (44 loc) · 1.46 KB
/
shellcheck.yml
File metadata and controls
54 lines (44 loc) · 1.46 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
name: Shell Lint
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
shellcheck:
runs-on: ubuntu-latest
defaults:
run:
shell: sh
steps:
- name: Checkout source
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install ShellCheck from apt
run: |
sudo apt-get update
sudo apt-get install -y shellcheck=0.9.0-1
shellcheck --version
- name: Run ShellCheck on changed .sh files in PR
if: github.event_name == 'pull_request'
run: |
set -eu
BASE_BRANCH="${{ github.base_ref }}"
git fetch origin "${BASE_BRANCH}" --depth=1
MERGE_BASE="$(git merge-base HEAD "origin/${BASE_BRANCH}")"
FILES="$(git diff --diff-filter=d --name-only "${MERGE_BASE}"...HEAD -- '*.sh')"
if [ -n "$FILES" ]; then
echo "Checking changed shell files:"
printf '%s\n' "$FILES"
printf '%s\n' "$FILES" | tr '\n' '\0' | xargs -0 -r shellcheck -s sh -e SC1091,SC2230,SC3043
else
echo "No shell files to lint."
fi
- name: Run ShellCheck on all .sh files (push/manual)
if: github.event_name != 'pull_request'
run: |
set -eu
echo "Linting all shell files in repository..."
find . -type f -name '*.sh' -print0 | xargs -0 -r shellcheck -s sh -e SC1091,SC2230,SC3043