diff --git a/.gitea/workflows/lint.yaml b/.gitea/workflows/lint.yaml index cae37ce..1e3d255 100644 --- a/.gitea/workflows/lint.yaml +++ b/.gitea/workflows/lint.yaml @@ -9,36 +9,64 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: bmuschko/setup-kubeconform@v1 name: Setup Kubeconform - - name: Kubeconform + + - name: Kubeconform validation id: kubeconform - continue-on-error: true run: | + # Create a temporary file to store validation output + VALIDATION_OUTPUT=$(mktemp) + + # Run kubeconform and capture output find . -name '*.yaml' \ ! -name '*values.yaml' \ ! -path './.gitea/*' \ -print0 \ | xargs -0 kubeconform \ -summary \ - -output text \ + -verbose \ + -output pretty \ -ignore-missing-schemas \ -schema-location default \ - -schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/kustomization.json' \ -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \ - | tee kubeconform_output.txt - - - name: Telegram notify on failure - if: failure() + -schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT 2>&1 + + # 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 + echo "VALIDATION_OUTPUT<> $GITHUB_ENV + cat $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 + continue-on-error: true + + - name: Telegram notify on validation failure + if: steps.kubeconform.outputs.status != '0' uses: appleboy/telegram-action@master with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} message: | - โŒ CI failed for ${{ github.repository }} - ๐Ÿ‘ค By: ${{ github.actor }} - ๐Ÿงช Commit: ${{ github.sha }} - ๐Ÿงพ Errors: - ${{ steps.kubeconform.outputs.stdout }} - - + ๐Ÿšจ Kubernetes manifest validation failed! + + Repository: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + + Validation errors: + ``` + ${{ env.VALIDATION_OUTPUT }} + ``` + + See full details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \ No newline at end of file