From a46f28afacc79b6a957d930583a39c8fdef525fe Mon Sep 17 00:00:00 2001 From: Erick Navarro Date: Tue, 5 Dec 2023 12:00:24 -0600 Subject: [PATCH] =?UTF-8?q?Inital=20commit=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 17 +++++++++++++++++ Dockerfile | 7 +++++++ README.md | 14 ++++++++++++++ action.yml | 5 +++++ entrypoint.sh | 22 ++++++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100755 .github/workflows/ci.yml create mode 100755 Dockerfile create mode 100755 README.md create mode 100755 action.yml create mode 100755 entrypoint.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100755 index 0000000..f534abc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +--- +name: CI + +on: push + +jobs: + run-linters: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Install shellcheck + run: sudo apt update && sudo apt install shellcheck --yes + + - name: Run shellcheck + run: shellcheck entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..ad71652 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.17 + +RUN apk --update add bash + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100755 index 0000000..e548af9 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Check manifest path + +Check `manifest_path` value in Kubernetes deployment manifest annotations, in case the value found is a path that doesn't exist it will break the job. + +This action will assume that the deployment manifest will use the word `manifest` in their paths. + +## Usage + +```yaml +- name: Update deployment container image + uses: resuelve/check-manifest-path-action@master +``` + +Enjoy 🎉 diff --git a/action.yml b/action.yml new file mode 100755 index 0000000..851dcac --- /dev/null +++ b/action.yml @@ -0,0 +1,5 @@ +--- +name: "Check manifest_path value in Kubernetes deployment manifest annotations" +runs: + using: "docker" + image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..55315ab --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# used to count all the errors +acc=0 + +for file in $(find . -iname "*.yml" | grep deployment); do + # we use xargs to trim result value, otherwise it will be ' "value"' + manifest_path=$(grep "manifest_path" "$file" | cut -f2 -d ":" | xargs) + if [ "$manifest_path" != "" ]; then + if [ ! -f "$manifest_path" ]; then + echo "$file has defined $manifest_path but this path doesn't exist" + acc=$((acc + 1)) + fi + + else + echo "$file doesn't have a manifest_path configured" + fi +done + +if [ "$acc" -gt "0" ]; then + exit 1 +fi