Skip to content

Commit

Permalink
Add CI job to lint Kubernetes manifests
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
shenanigansd authored Jul 18, 2023
1 parent b6e0041 commit b7029d2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/kubernetes-ci.yaml
Original file line number Diff line number Diff line change
@@ -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<<EOF" >> $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 }}
16 changes: 16 additions & 0 deletions scripts/find_manifests.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit b7029d2

Please sign in to comment.