diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 00000000..d5895911 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,30 @@ +name: shellcheck + +on: + pull_request: + paths: + - '**.sh' + +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: changed shell scripts + id: changed-files + uses: tj-actions/changed-files@v39 + with: + files_yaml: | + shell: + - '**.sh' + + - name: run shellcheck for all changed shell scripts + if: steps.changed-files.outputs.shell_any_changed == 'true' + run: | + # https://github.com/rhysd/actionlint/issues/355 + # shellcheck disable=SC2043 + for file in ${{ steps.changed-files.outputs.shell_all_changed_files }}; do + echo "$file was changed" + shellcheck "$file" + done diff --git a/test-2.sh b/test-2.sh new file mode 100644 index 00000000..54c88f6a --- /dev/null +++ b/test-2.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "test-2" diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..6e7fbe24 --- /dev/null +++ b/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "test"