forked from ab/homelab
Update .gitea/workflows/lint.yaml
This commit is contained in:
@ -13,64 +13,49 @@ 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 for storing validation output
|
||||||
VALIDATION_OUTPUT_FILE=$(mktemp)
|
VALIDATION_OUTPUT=$(mktemp)
|
||||||
|
|
||||||
# Run kubeconform and capture output and exit code
|
# Run kubeconform and capture output
|
||||||
find . -name '*.yaml' \
|
find . -name '*.yaml' \
|
||||||
! -name '*values.yaml' \
|
! -name '*values.yaml' \
|
||||||
! -path './.gitea/*' \
|
! -path './.gitea/*' \
|
||||||
-print0 | xargs -0 kubeconform \
|
-print0 \
|
||||||
-summary \
|
| xargs -0 kubeconform \
|
||||||
-verbose \
|
-summary \
|
||||||
-output pretty \
|
-verbose \
|
||||||
-ignore-missing-schemas \
|
-output pretty \
|
||||||
-schema-location default \
|
-ignore-missing-schemas \
|
||||||
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
-schema-location default \
|
||||||
-schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT_FILE 2>&1 || true
|
-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 || true
|
||||||
|
|
||||||
# Save the validation output to a step output
|
# Display output in logs
|
||||||
VALIDATION_OUTPUT=$(cat $VALIDATION_OUTPUT_FILE)
|
cat $VALIDATION_OUTPUT
|
||||||
echo "VALIDATION_OUTPUT<<EOF" >> $GITHUB_ENV
|
|
||||||
echo "$VALIDATION_OUTPUT" >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
# Display the output in the logs
|
# Extract invalid files to a list
|
||||||
cat $VALIDATION_OUTPUT_FILE
|
if grep -q "invalid" $VALIDATION_OUTPUT; then
|
||||||
|
grep -o "[^ ]*.yaml:.*invalid" $VALIDATION_OUTPUT | sort | uniq > invalid_files.txt
|
||||||
# Check if there were validation errors
|
echo "FAILED=true" >> $GITHUB_ENV
|
||||||
if grep -q "Error" $VALIDATION_OUTPUT_FILE; then
|
|
||||||
echo "VALIDATION_FAILED=true" >> $GITHUB_ENV
|
|
||||||
echo "::error::Kubernetes manifest validation failed!"
|
echo "::error::Kubernetes manifest validation failed!"
|
||||||
|
cat invalid_files.txt
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "All manifests are valid!"
|
echo "All manifests are valid!"
|
||||||
fi
|
fi
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Extract invalid files
|
- name: Telegram notify on failure
|
||||||
if: env.VALIDATION_FAILED == 'true'
|
if: env.FAILED == 'true'
|
||||||
id: extract_errors
|
|
||||||
run: |
|
|
||||||
echo "INVALID_FILES<<EOF" >> $GITHUB_ENV
|
|
||||||
grep -o "[^ ]*.yaml:.*Error:" <<< "${{ env.VALIDATION_OUTPUT }}" | sort | uniq >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Telegram notify on validation failure
|
|
||||||
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 }}
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
message: |
|
message: |
|
||||||
🚨 Kubernetes manifest validation failed!
|
❌ Kubernetes validation failed!
|
||||||
|
|
||||||
Repository: ${{ github.repository }}
|
Invalid files:
|
||||||
Files with errors:
|
$(cat invalid_files.txt)
|
||||||
${{ env.INVALID_FILES }}
|
|
||||||
|
|
||||||
Check action: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
Reference in New Issue
Block a user