From b7029d225aed171fed82a61baf2871c1cb0d070e Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Tue, 18 Jul 2023 19:20:52 +0000 Subject: [PATCH] Add CI job to lint Kubernetes manifests Signed-off-by: GitHub --- .github/workflows/kubernetes-ci.yaml | 28 ++++++++++++++++++++++++++++ scripts/find_manifests.py | 16 ++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/kubernetes-ci.yaml create mode 100644 scripts/find_manifests.py diff --git a/.github/workflows/kubernetes-ci.yaml b/.github/workflows/kubernetes-ci.yaml new file mode 100644 index 0000000..c3b1157 --- /dev/null +++ b/.github/workflows/kubernetes-ci.yaml @@ -0,0 +1,28 @@ +name: "CI - Kubernetes" + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + name: "Lint manifests" + + runs-on: ubuntu-latest + + steps: + - name: "Checkout code" + uses: actions/checkout@v3 + + - id: manifest-files + name: "Find manifest files" + run: | + echo "manifests<> $GITHUB_OUTPUT + python scripts/find_manifests.py >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - uses: azure/k8s-lint@v1 + with: + manifests: ${{ steps.manifest-files.outputs.manifests }} diff --git a/scripts/find_manifests.py b/scripts/find_manifests.py new file mode 100644 index 0000000..cdb0e87 --- /dev/null +++ b/scripts/find_manifests.py @@ -0,0 +1,16 @@ +import os +from pathlib import Path + +potential_manifests = Path(".").glob("**/*.yaml") + +likely_manifests = [] + +for file in potential_manifests: + if "apiVersion:" in file.read_text(): + # File is likely a k8s manifests + + # Ignore manifests that start with _ + if not file.stem.startswith("_"): + likely_manifests.append(str(file)) + +print("\n".join(likely_manifests))