-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (47 loc) · 1.91 KB
/
Copy pathbash.yml
File metadata and controls
54 lines (47 loc) · 1.91 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 Script Security (Bash)
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
permissions:
contents: read
jobs:
shellcheck_scan:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4 # Updated to v4 for latest features and security
- name: Setup ShellCheck
run: |
echo "Installing ShellCheck..."
sudo apt-get update
sudo apt-get install -y shellcheck
echo "ShellCheck setup complete."
- name: ShellCheck Scan
shell: bash
run: |
echo "Starting ShellCheck scan for .sh files in the root directory starting with A3PT..."
# Create a temporary file to store the list of shell scripts
# Using mktemp for robust temporary file creation
file_list=$(mktemp)
# Find .sh files only in the root directory, starting with A3PT, and exclude dot-folders
find . -maxdepth 1 -type f -name "A3PT*.sh" -print0 > "$file_list"
# Check if any shell scripts were found
if [ -s "$file_list" ]; then
echo "--- ShellCheck Issues ---"
# Run shellcheck on the found files.
# xargs -0 reads null-separated arguments from stdin.
# Shellcheck will print issues to stdout/stderr and exit with a non-zero status if issues are found.
if xargs -0 shellcheck < "$file_list"; then
echo "ShellCheck completed: No issues found in shell scripts."
else
echo "ShellCheck completed: Issues found in shell scripts."
exit 1 # Fail the step if shellcheck found issues
fi
echo "-------------------------"
else
echo "No shell scripts (.sh files) found in the root directory starting with A3PT to scan."
fi
# Clean up the temporary file
rm -f "$file_list"