From a045ccda6699e6f785472649e0a2155a2fdce333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Pogeant?= Date: Mon, 13 Apr 2020 16:05:58 +0200 Subject: [PATCH] Create golint GitHub action --- CODEOWNERS | 1 + Dockerfile | 5 +++++ README.md | 25 +++++++++++++++++++++++-- action.yml | 19 +++++++++++++++++++ entrypoint.sh | 13 +++++++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 CODEOWNERS create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..a3484cf --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @Jerome1337 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f05ab5f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM cytopia/golint + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index ac6bba0..c836033 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,23 @@ -# golint-action -Ready to use go lint GitHub action +# Golint action + +This action execute golint command and return the output if the command fail. + +## Inputs + +### `golint-path` + +Path used by golint command, default is `./...`. + +## Outputs + +### `golint-output` + +The golint output if the command fail. + +## Example usage + +```yaml +uses: Jerome1337/go-action/lint@v1.0.0 +with: + golint-path: './src/...' +```` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..0241f76 --- /dev/null +++ b/action.yml @@ -0,0 +1,19 @@ +name: 'Go-linter' +author: 'Jérôme Pogeant' +description: 'Lint your code using golint' +inputs: + golint-path: + description: 'Path used by golint command' + required: false + default: './...' +outputs: + golint-output: + description: 'The golint output if the command fail' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.golint-path }} +branding: + icon: 'check-circle' + color: 'green' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..f8924d5 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh -l + +cd $GITHUB_WORKSPACE + +GOLINT_OUTPUT="$(golint -set_exit_status $1)" + +if [ $? -ne 0 ]; then + echo "${GOLINT_OUTPUT}" + + exit 1 +fi + +echo "::set-output name=golint-output::Golint step succeed"