From e19896e3a05c864c27c5c251146c96bc47e083f2 Mon Sep 17 00:00:00 2001 From: guzhongren Date: Sat, 22 Jan 2022 15:24:50 +0800 Subject: [PATCH] feat(shellcheck): add shell check for shell and pipeline --- .github/workflows/main.yml | 10 ++-------- docker-compose.yaml | 8 ++++++++ validate.sh | 11 +++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 docker-compose.yaml create mode 100755 validate.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30a4bc1..c0ed349 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,11 +26,5 @@ jobs: - uses: actions/checkout@v2 # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! - - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. + - name: shell check + run: docker-compose run --rm shellcheck ./validate.sh diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..4349a5a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +--- +version: '3.9' +services: + shellcheck: + image: koalaman/shellcheck-alpine:latest + volumes: + - ".:/build" + working_dir: /build diff --git a/validate.sh b/validate.sh new file mode 100755 index 0000000..c732d71 --- /dev/null +++ b/validate.sh @@ -0,0 +1,11 @@ +#!/bin/sh -l + +set -euo pipefile + +rc=0 +for filename in $(find ./* -name '*.sh'); do + echo "Validating" + shellcheck "${filename}" || exit $? +done + +exit $? \ No newline at end of file