updated shellcheck workflow

This commit is contained in:
Andrey Prokopenko
2021-09-25 12:04:16 +02:00
parent a283542850
commit 762993e7e8
2 changed files with 30 additions and 18 deletions

View File

@@ -1,24 +1,11 @@
name: shellcheck
on:
push:
branches: [master, develop]
pull_request:
branches: [master]
on: pull_request
jobs:
Shellcheck:
name: Shellcheck
test:
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v2
- name: Check scripts with Shellcheck
uses: essentialkaos/shellcheck-action@v1
with:
files: hetzner-debian10-zfs-setup.sh hetzner-debian11-zfs-setup.sh hetzner-ubuntu18-zfs-setup.sh hetzner-ubuntu20-zfs-setup.sh
severity: error
format: gcc
shell: bash
- uses: actions/checkout@v2
- name: Run shellcheck
run: ci/run_shellcheck.sh

25
ci/run_shellcheck.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -o pipefail
set -o errexit
set -o nounset
set -o errtrace
shopt -s inherit_errexit
# Always download the latest version:
#
# - it's fast and stable enough not to worry about it;
# - the workflow is basically single-person, so there's no risk of a new dev encountering an error found
# by a new shellcheck version.
mkdir -p /opt/shellcheck
wget -qO- https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz \
| tar xJv -O shellcheck-stable/shellcheck \
> /opt/shellcheck/shellcheck
chmod +x /opt/shellcheck/shellcheck
/opt/shellcheck/shellcheck --version
grep -lZP '^#!/bin/\w+sh' -R | xargs -0 /opt/shellcheck/shellcheck