forked from ab/homelab
Update .gitea/workflows/lint.yaml
This commit is contained in:
@ -13,46 +13,46 @@ jobs:
|
|||||||
- uses: bmuschko/setup-kubeconform@v1
|
- uses: bmuschko/setup-kubeconform@v1
|
||||||
name: Setup Kubeconform
|
name: Setup Kubeconform
|
||||||
|
|
||||||
|
# This is the step that was missing in your workflow execution
|
||||||
- name: Kubeconform validation
|
- name: Kubeconform validation
|
||||||
id: kubeconform
|
id: kubeconform
|
||||||
run: |
|
run: |
|
||||||
# Create a temporary file to store validation output
|
# 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' \
|
find . -name '*.yaml' \
|
||||||
! -name '*values.yaml' \
|
! -name '*values.yaml' \
|
||||||
! -path './.gitea/*' \
|
! -path './.gitea/*' \
|
||||||
-print0 \
|
-print0 | xargs -0 kubeconform \
|
||||||
| xargs -0 kubeconform \
|
|
||||||
-summary \
|
-summary \
|
||||||
-verbose \
|
-verbose \
|
||||||
-output pretty \
|
-output pretty \
|
||||||
-ignore-missing-schemas \
|
-ignore-missing-schemas \
|
||||||
-schema-location default \
|
-schema-location default \
|
||||||
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
-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
|
-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
|
# Save the validation output to a step output
|
||||||
VALIDATION_EXIT_CODE=$?
|
VALIDATION_OUTPUT=$(cat $VALIDATION_OUTPUT_FILE)
|
||||||
|
|
||||||
# Output the content for logs
|
|
||||||
cat $VALIDATION_OUTPUT
|
|
||||||
|
|
||||||
# Store the validation output in a file for the next step
|
|
||||||
echo "VALIDATION_OUTPUT<<EOF" >> $GITHUB_ENV
|
echo "VALIDATION_OUTPUT<<EOF" >> $GITHUB_ENV
|
||||||
cat $VALIDATION_OUTPUT >> $GITHUB_ENV
|
echo "$VALIDATION_OUTPUT" >> $GITHUB_ENV
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Set output variable to indicate validation status
|
# Check if there were validation errors
|
||||||
echo "status=$VALIDATION_EXIT_CODE" >> $GITHUB_OUTPUT
|
if grep -q "Error" $VALIDATION_OUTPUT_FILE; then
|
||||||
|
echo "VALIDATION_FAILED=true" >> $GITHUB_ENV
|
||||||
# Exit with the same code as kubeconform
|
echo "::error::Kubernetes manifest validation failed!"
|
||||||
exit $VALIDATION_EXIT_CODE
|
echo "$VALIDATION_OUTPUT"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "All manifests are valid!"
|
||||||
|
echo "$VALIDATION_OUTPUT"
|
||||||
|
fi
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Telegram notify on validation failure
|
- name: Telegram notify on validation failure
|
||||||
if: steps.kubeconform.outputs.status != '0'
|
if: env.VALIDATION_FAILED == 'true'
|
||||||
uses: appleboy/telegram-action@master
|
uses: appleboy/telegram-action@master
|
||||||
with:
|
with:
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
Reference in New Issue
Block a user