backup-automation/.forgejo/workflows/lint-bash.yml

45 lines
1.1 KiB
YAML
Raw Normal View History

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' -print0 > shell-scripts.list
- name: Run ShellCheck in Script Directories
run: |
echo "Running ShellCheck in each script's directory..."
while IFS= read -r -d '' 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