From 410e596506e78206e6b7ff573d332343d9fe6fed Mon Sep 17 00:00:00 2001 From: ab Date: Sun, 13 Apr 2025 11:21:55 +0000 Subject: [PATCH] Update .gitea/workflows/lint.yaml --- .gitea/workflows/lint.yaml | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.gitea/workflows/lint.yaml b/.gitea/workflows/lint.yaml index 1e3d255..68e2165 100644 --- a/.gitea/workflows/lint.yaml +++ b/.gitea/workflows/lint.yaml @@ -13,46 +13,46 @@ jobs: - uses: bmuschko/setup-kubeconform@v1 name: Setup Kubeconform + # This is the step that was missing in your workflow execution - name: Kubeconform validation id: kubeconform run: | # Create a temporary file to store validation output - VALIDATION_OUTPUT=$(mktemp) + VALIDATION_OUTPUT_FILE=$(mktemp) - # Run kubeconform and capture output + # Run kubeconform and capture output and exit code find . -name '*.yaml' \ ! -name '*values.yaml' \ ! -path './.gitea/*' \ - -print0 \ - | xargs -0 kubeconform \ - -summary \ - -verbose \ - -output pretty \ - -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/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT 2>&1 + -print0 | xargs -0 kubeconform \ + -summary \ + -verbose \ + -output pretty \ + -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/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT_FILE 2>&1 || true - # Store exit code - VALIDATION_EXIT_CODE=$? - - # Output the content for logs - cat $VALIDATION_OUTPUT - - # Store the validation output in a file for the next step + # Save the validation output to a step output + VALIDATION_OUTPUT=$(cat $VALIDATION_OUTPUT_FILE) echo "VALIDATION_OUTPUT<> $GITHUB_ENV - cat $VALIDATION_OUTPUT >> $GITHUB_ENV + echo "$VALIDATION_OUTPUT" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - # Set output variable to indicate validation status - echo "status=$VALIDATION_EXIT_CODE" >> $GITHUB_OUTPUT - - # Exit with the same code as kubeconform - exit $VALIDATION_EXIT_CODE + # Check if there were validation errors + if grep -q "Error" $VALIDATION_OUTPUT_FILE; then + echo "VALIDATION_FAILED=true" >> $GITHUB_ENV + echo "::error::Kubernetes manifest validation failed!" + echo "$VALIDATION_OUTPUT" + exit 1 + else + echo "All manifests are valid!" + echo "$VALIDATION_OUTPUT" + fi continue-on-error: true - name: Telegram notify on validation failure - if: steps.kubeconform.outputs.status != '0' + if: env.VALIDATION_FAILED == 'true' uses: appleboy/telegram-action@master with: to: ${{ secrets.TELEGRAM_TO }}