diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c0ed349 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,30 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a single command using the runners shell + - 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/entrypoint.sh b/entrypoint.sh index 62b60d3..e6d574c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,10 @@ -#!/bin/sh -l +#!/bin/sh +# shellcheck disable=SC3060 set -e # if a command fails it stops the execution set -u # script fails if trying to access to an undefined variable echo "[+] Action start" -SOURCE_BEFORE_DIRECTORY="${1}" SOURCE_DIRECTORY="${2}" DESTINATION_GITHUB_USERNAME="${3}" DESTINATION_REPOSITORY_NAME="${4}" diff --git a/validate.sh b/validate.sh new file mode 100755 index 0000000..0536b4c --- /dev/null +++ b/validate.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# shellcheck disable=SC2044 + +set -eu pipefile + +rc=0 +for filename in $(find ./* -name '*.sh'); do + echo "Start to validating ${filename}" + shellcheck "${filename}" || exit $? + echo "🚀Successfully Validated ${filename}" +done + +exit $rc \ No newline at end of file