Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Commit

Permalink
42
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Steinbrück committed Apr 14, 2020
1 parent aabb4c6 commit 3e47a62
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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" ]
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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'
23 changes: 23 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 3e47a62

Please sign in to comment.