From 3e47a62105860618a151aee2a54037c76a40b6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Steinbr=C3=BCck?= Date: Tue, 14 Apr 2020 15:25:36 +0200 Subject: [PATCH] 42 --- Dockerfile | 20 ++++++++++++++++++++ action.yml | 26 ++++++++++++++++++++++++++ entrypoint.sh | 23 +++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c6a7ab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:alpine3.11 + +LABEL name="prometheus-operator-lint-action" +LABEL repository="http://github.com/p1nkun1c0rns/prometheus-operator-lint-action" +LABEL homepage="http://github.com/p1nkun1c0rns/prometheus-operator-lint-action" +LABEL maintainer="Richard Steinbrueck " + +ENV GO111MODULE on +ENV PO_LINT_VERSION 0.38.0 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# hadolint ignore=DL3018 +RUN apk add --no-cache \ + git + +RUN go get -u github.com/coreos/prometheus-operator/cmd/po-lint@v${PO_LINT_VERSION} + +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..58a8ad3 --- /dev/null +++ b/action.yml @@ -0,0 +1,26 @@ +name: 'Prometheus Operator Lint Action' +author: 'Richard Steinbrueck' +description: 'Run po-lint on your yaml files' +inputs: + path: + description: 'Path to scan for files within the directory (and nested directories)' + required: false + default: './' + file_extension: + description: '' + required: false + default: '*.yaml' + exclude: + description: 'should be a substring of the folder path you want to exclude' + required: false + default: '' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.path }} + - ${{ inputs.file_extension }} + - ${{ inputs.exclude }} +branding: + icon: 'terminal' + color: 'red' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f20ddfa --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +INPUT_PATH=$1 +INPUT_FILES=$2 +INPUT_EXCLUDE=$3 + +echo "Linting '${INPUT_FILES}' files in directory '${INPUT_PATH}'..." +had_errors=0 +for file in $(find ${INPUT_PATH} -name ${INPUT_FILES}); do + # Exclude Grafana dashboards + if echo "${file}" | grep -q ${INPUT_EXCLUDE} + then + echo "skip -> ${file}" + continue + fi + + po-lint "${file}" + retval=$? + if [ $retval -ne 0 ]; then + had_errors=1 + fi +done +exit ${had_errors}