| 1 |
name: CheckScripts |
| 2 |
|
| 3 |
# spell-checker:ignore ludeeus mfinelli shellcheck scandir shfmt |
| 4 |
|
| 5 |
env: |
| 6 |
SCRIPT_DIR: 'util' |
| 7 |
|
| 8 |
on: |
| 9 |
push: |
| 10 |
branches: |
| 11 |
- '*' |
| 12 |
paths: |
| 13 |
- 'util/**/*.sh' |
| 14 |
pull_request: |
| 15 |
branches: |
| 16 |
- main |
| 17 |
paths: |
| 18 |
- 'util/**/*.sh' |
| 19 |
|
| 20 |
# End the current execution if there is a new changeset in the PR. |
| 21 |
concurrency: |
| 22 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 23 |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 24 |
|
| 25 |
jobs: |
| 26 |
shell_check: |
| 27 |
name: ShellScript/Check |
| 28 |
runs-on: ubuntu-latest |
| 29 |
permissions: |
| 30 |
contents: read |
| 31 |
steps: |
| 32 |
- uses: actions/[email protected] |
| 33 |
with: |
| 34 |
persist-credentials: false |
| 35 |
- name: Run ShellCheck |
| 36 |
uses: ludeeus/action-shellcheck@master |
| 37 |
env: |
| 38 |
SHELLCHECK_OPTS: -s bash |
| 39 |
with: |
| 40 |
severity: warning |
| 41 |
scandir: ${{ env.SCRIPT_DIR }} |
| 42 |
format: tty |
| 43 |
|
| 44 |
shell_fmt: |
| 45 |
name: ShellScript/Format |
| 46 |
runs-on: ubuntu-latest |
| 47 |
permissions: |
| 48 |
contents: read |
| 49 |
steps: |
| 50 |
- uses: actions/[email protected] |
| 51 |
with: |
| 52 |
persist-credentials: false |
| 53 |
- name: Setup shfmt |
| 54 |
uses: mfinelli/setup-shfmt@v4 |
| 55 |
- name: Run shfmt |
| 56 |
shell: bash |
| 57 |
run: | |
| 58 |
# fmt options: bash syntax, 4 spaces indent, indent for switch-case |
| 59 |
echo "## show the differences between formatted and original scripts..." |
| 60 |
find ${{ env.SCRIPT_DIR }} -name "*.sh" -print0 | xargs -0 shfmt -ln=bash -i 4 -ci -d || true |