ProxmoxVE/.github/workflows/shellcheck.yml
2025-01-14 14:35:51 +01:00

71 lines
2.1 KiB
YAML

name: Shellcheck
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: "5 1 * * *"
jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: |
**.sh
# This is a manual copy from https://github.com/ludeeus/action-shellcheck/blob/00b27aa7cb85167568cb48a3838b75f4265f2bca/action.yaml#L59
# Why? Because the action is not capable of adding ONLY a list of files.
# We aim to only check the files that have changed.
# This is used as we deal with a codebase that throws a lot of warnings.
# Checking only the changed files is a good compromise to improve the codebase over time.
- name: Download shellcheck
shell: bash
env:
INPUT_VERSION: "v0.10.0"
run: |
set -euo pipefail
if [[ "${{ runner.os }}" == "macOS" ]]; then
osvariant="darwin"
else
osvariant="linux"
fi
baseurl="https://github.com/koalaman/shellcheck/releases/download"
# ShellCheck herunterladen ins Arbeitsverzeichnis
curl -Lso "${{ github.workspace }}/sc.tar.xz" \
"${baseurl}/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz"
# Entpacken und verschieben
tar -xf "${{ github.workspace }}/sc.tar.xz" -C "${{ github.workspace }}"
mv "${{ github.workspace }}/shellcheck-${INPUT_VERSION}/shellcheck" \
"${{ github.workspace }}/shellcheck"
# Debugging: Zeige den Pfad und die Datei
echo "ShellCheck binary path:"
ls -l "${{ github.workspace }}/shellcheck"
- name: Display shellcheck version
shell: bash
run: |
"${{ github.action_path }}/shellcheck" --version
- name: Run ShellCheck
if: steps.changed-files-specific.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "${ALL_CHANGED_FILES}" | xargs shellcheck