Skip to content

Commit 732c37c

Browse files
committed
CI: Improve ShellCheck workflow to skip deleted files in PRs
- Updated shellcheck GitHub Actions workflow to exclude deleted .sh files during pull request linting using --diff-filter=d. - Ensures ShellCheck runs only on existing, modified shell scripts in PRs. - Retains full linting on push and manual workflow_dispatch events. - Removed use of 'realpath' to avoid issues with non-existent files. Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent c0ddc36 commit 732c37c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

.github/workflows/shellcheck.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
run: |
2626
echo "Checking only changed shell files in PR..."
2727
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)
28+
FILES=$(git diff --diff-filter=d --name-only origin/${{ github.base_ref }} -- '*.sh')
2929
if [ -n "$FILES" ]; then
30-
echo "$FILES" | tr ' ' '\n' | xargs -r shellcheck -S warning -e SC1091,SC2230,SC3043
30+
echo "$FILES" | tr '\n' '\0' | xargs -0 -r shellcheck -S warning -e SC1091,SC2230,SC3043
3131
else
3232
echo "No shell files to lint."
3333
fi

0 commit comments

Comments
 (0)