Simplify workflow: run shellcheck once, remove duplicate execution #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Shellcheck Lint | |
| on: | |
| push: | |
| paths: | |
| # Run workflow on every push | |
| # only if a file within the specified paths has been changed: | |
| - 'rbme' | |
| - '.github/workflows/shellcheck.yml' | |
| pull_request: | |
| paths: | |
| # Run workflow on every push | |
| # only if a file within the specified paths has been changed: | |
| - 'rbme' | |
| - '.github/workflows/shellcheck.yml' | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Restrict permissions for pull requests to read-only for security | |
| permissions: | |
| contents: read | |
| jobs: | |
| shellcheck: | |
| name: Shellcheck Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Required to access files of this repository | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Verify that Shellcheck is available | |
| - name: Check Shellcheck Version | |
| run: | | |
| shellcheck --version | |
| # Run Shellcheck on repository with detailed output | |
| # --- | |
| # https://github.com/koalaman/shellcheck | |
| # --- | |
| # Excluded checks: | |
| # https://www.shellcheck.net/wiki/SC1091 -- Not following: /etc/rc.status was... | |
| # https://www.shellcheck.net/wiki/SC1090 -- Can't follow non-constant source. .. | |
| # --- | |
| - name: Run Shellcheck | |
| run: | | |
| set +e | |
| find ./ -maxdepth 1 -type f -name rbme | while read -r sh; do | |
| if [ "$(file --brief --mime-type "$sh")" == 'text/x-shellscript' ]; then | |
| echo "shellcheck'ing $sh" | |
| if ! shellcheck --color=always --severity=warning --exclude=SC1091,SC1090 "$sh"; then | |
| touch some_scripts_have_failed_shellcheck | |
| fi | |
| fi | |
| done | |
| if [ -f ./some_scripts_have_failed_shellcheck ]; then | |
| echo "Shellcheck failed for one or more shellscript(s)" | |
| exit 1 | |
| fi | |