backup-automation/.forgejo/workflows/lint-bash.yml
ZoopaMario 6f394a867a
All checks were successful
Check Commit Messages / check-commit-message (pull_request) Successful in 52s
Lint Bash Scripts / lint-bash (pull_request) Successful in 30s
Lint Bash Scripts / lint-bash (push) Successful in 26s
Refactor code to make linter runs succeed
This commit refactors the codebase in order to make the shellcheck
workflow pass.
2024-12-29 19:32:26 +01:00

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