ZoopaMario
6f394a867a
This commit refactors the codebase in order to make the shellcheck workflow pass.
52 lines
1.3 KiB
YAML
52 lines
1.3 KiB
YAML
name: Lint Bash Scripts
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- '**/*.sh'
|
|
pull_request:
|
|
paths:
|
|
- '**/*.sh'
|
|
|
|
jobs:
|
|
lint-bash:
|
|
runs-on: docker
|
|
container:
|
|
image: node:16-bullseye
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install ShellCheck
|
|
run: |
|
|
apt-get update && apt-get install -y shellcheck
|
|
|
|
- name: Find Shell Scripts
|
|
id: find-scripts
|
|
run: |
|
|
echo "Searching for shell scripts..."
|
|
find . -name '*.sh' > shell-scripts.list
|
|
echo "Found the following scripts:"
|
|
cat shell-scripts.list
|
|
|
|
- name: Run ShellCheck in Script Directories
|
|
shell: bash
|
|
run: |
|
|
echo "Running ShellCheck in each script's directory..."
|
|
if [ ! -s shell-scripts.list ]; then
|
|
echo "No shell scripts found."
|
|
exit 0
|
|
fi
|
|
|
|
while IFS= read -r script; do
|
|
echo "Checking $script"
|
|
script_dir=$(dirname "$script")
|
|
script_name=$(basename "$script")
|
|
# Change to the script's directory and run ShellCheck
|
|
(cd "$script_dir" && shellcheck -x "$script_name")
|
|
done < shell-scripts.list
|
|
|