forked from ab/homelab
59 lines
1.9 KiB
YAML
59 lines
1.9 KiB
YAML
name: Check with kubeconform
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: bmuschko/setup-kubeconform@v1
|
|
name: Setup Kubeconform
|
|
|
|
- name: Validate manifests
|
|
id: kubeconform
|
|
run: |
|
|
invalid_files=$(
|
|
find . -name '*.yaml' ! -name '*values.yaml' ! -path './.gitea/*' -print0 |
|
|
xargs -0 kubeconform \
|
|
-summary \
|
|
-output json \
|
|
-ignore-missing-schemas \
|
|
-schema-location default \
|
|
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
|
-schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/kustomization.json' |
|
|
jq -r '.resources[] | select(.status == "invalid") | "- \(.filename): \(.msg)"'
|
|
)
|
|
|
|
if [[ -n "$invalid_files" ]]; then
|
|
{
|
|
echo 'FAILED=true'
|
|
echo "INVALID_FILES<<EOF"
|
|
echo "$invalid_files"
|
|
echo "EOF"
|
|
} >> "$GITHUB_ENV"
|
|
echo "::error::Validation failed!"
|
|
exit 1
|
|
else
|
|
echo "✅ All manifests are valid!"
|
|
fi
|
|
continue-on-error: true
|
|
|
|
- name: Notify Telegram on failure
|
|
if: env.FAILED == 'true'
|
|
uses: appleboy/telegram-action@master
|
|
with:
|
|
to: ${{ secrets.TELEGRAM_TO }}
|
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
format: html
|
|
message: |
|
|
❌ <b>Kubernetes validation failed!</b>
|
|
|
|
<b>Invalid files:</b>
|
|
<pre>${{ env.INVALID_FILES }}</pre>
|
|
|
|
🔗 <a href="https://gt.hexor.cy/${{ github.repository }}/actions/runs/${{ github.run_number }}">Details</a>
|