diff --git a/.gitea/workflows/lint.yaml b/.gitea/workflows/lint.yaml index 0945c20..9992539 100644 --- a/.gitea/workflows/lint.yaml +++ b/.gitea/workflows/lint.yaml @@ -14,36 +14,32 @@ jobs: 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)"' - ) + 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' \ + > kubeconform_output.json - if [[ -n "$invalid_files" ]]; then - { - echo 'FAILED=true' - echo "INVALID_FILES<> "$GITHUB_ENV" - echo "::error::Validation failed!" + invalid_count=$(jq '[.resources[] | select(.status=="invalid")] | length' kubeconform_output.json) + + if [[ "$invalid_count" -gt 0 ]]; then + jq -r '.resources[] | select(.status=="invalid") | "- \(.filename): \(.msg)"' kubeconform_output.json > invalid_files.txt + cat invalid_files.txt + echo "::error::Validation failed with $invalid_count errors." exit 1 else - echo "✅ All manifests are valid!" + echo "✅ All manifests valid!" fi - continue-on-error: true - name: Notify Telegram on failure - if: env.FAILED == 'true' + if: failure() uses: appleboy/telegram-action@master with: to: ${{ secrets.TELEGRAM_TO }} @@ -53,6 +49,6 @@ jobs: ❌ Kubernetes validation failed! Invalid files: -
${{ env.INVALID_FILES }}
+
${{ join(files('invalid_files.txt'), '\n') }}
🔗 Details