diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index fef6ef1..5d0e147 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: docker image on: [push] diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml new file mode 100644 index 0000000..6096b5e --- /dev/null +++ b/.github/workflows/golangci.yml @@ -0,0 +1,16 @@ +name: golangci +on: [pull_request] +jobs: + golangci-lint-dockerfile: + name: lint + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + - name: golangci-lint + uses: ./ + with: + github_token: ${{ secrets.github_token }} + directory: sample + format: colored-line-number + flags: --issues-exit-code 0 diff --git a/Dockerfile b/Dockerfile index e8f3902..1a321d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,5 @@ FROM golangci/golangci-lint:v1.25 + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index dbf8e47..1694dff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # golangci-lint-action Work in progress + +Based on [reviewdog action](https://github.com/reviewdog/action-golangci-lint). diff --git a/action.yml b/action.yml index 4762db3..b6ba408 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,19 @@ inputs: github_token: description: 'GITHUB_TOKEN' required: true + flags: + description: 'GolangCI command line flags' + required: false + directory: + description: 'Working directory' + required: false + default: '' + format: + description: 'Output format of issues' + default: 'github-actions' + required: false + + runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index b63311a..ad37aab --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,3 +1,10 @@ #!/bin/bash -golangci-lint run --out-format github-actions +echo 'golangci-lint-action: start' +echo " flags: ${INPUT_FLAGS}" +echo " format: ${INPUT_FORMAT}" + +cd "${GITHUB_WORKSPACE}/${INPUT_DIRECTORY}" || exit 1 + +# shellcheck disable=SC2086 +golangci-lint run --out-format ${INPUT_FORMAT} ${INPUT_FLAGS} diff --git a/sample/sample.go b/sample/sample.go new file mode 100644 index 0000000..50071d0 --- /dev/null +++ b/sample/sample.go @@ -0,0 +1,14 @@ +// Package sample is used as test input for golangci action. +package sample + +import ( + "crypto/md5" + "encoding/hex" +) + +// Hash~ +func Hash(data string) string { + h := md5.New() + h.Write([]byte(data)) + return hex.EncodeToString(h.Sum(nil)) +}