Update .gitea/workflows/lint.yaml
All checks were successful
Check with kubeconform / lint (push) Successful in 6s
All checks were successful
Check with kubeconform / lint (push) Successful in 6s
This commit is contained in:
@@ -13,51 +13,36 @@ jobs:
|
|||||||
- uses: bmuschko/setup-kubeconform@v1
|
- uses: bmuschko/setup-kubeconform@v1
|
||||||
name: Setup Kubeconform
|
name: Setup Kubeconform
|
||||||
|
|
||||||
- name: Kubeconform validation
|
- name: Validate manifests
|
||||||
id: kubeconform
|
id: kubeconform
|
||||||
run: |
|
run: |
|
||||||
# Create a temporary file for storing validation output
|
invalid_files=$(
|
||||||
VALIDATION_OUTPUT=$(mktemp)
|
find . -name '*.yaml' ! -name '*values.yaml' ! -path './.gitea/*' -print0 |
|
||||||
|
xargs -0 kubeconform \
|
||||||
# Run kubeconform and capture output
|
|
||||||
find . -name '*.yaml' \
|
|
||||||
! -name '*values.yaml' \
|
|
||||||
! -path './.gitea/*' \
|
|
||||||
-print0 \
|
|
||||||
| xargs -0 kubeconform \
|
|
||||||
-summary \
|
-summary \
|
||||||
-verbose \
|
-output json \
|
||||||
-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 || true
|
-schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/kustomization.json' |
|
||||||
|
jq -r '.resources[] | select(.status == "invalid") | "- \(.filename): \(.msg)"'
|
||||||
|
)
|
||||||
|
|
||||||
# Display output in logs
|
if [[ -n "$invalid_files" ]]; then
|
||||||
cat $VALIDATION_OUTPUT
|
{
|
||||||
|
echo 'FAILED=true'
|
||||||
# Extract invalid files to a list
|
echo "INVALID_FILES<<EOF"
|
||||||
if grep -q "invalid" $VALIDATION_OUTPUT; then
|
echo "$invalid_files"
|
||||||
grep -o "[^ ]*.yaml:.*invalid" $VALIDATION_OUTPUT | sort | uniq > invalid_files.txt
|
echo "EOF"
|
||||||
echo "FAILED=true" >> $GITHUB_ENV
|
} >> "$GITHUB_ENV"
|
||||||
echo "::error::Kubernetes manifest validation failed!"
|
echo "::error::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: Build notification message
|
- name: Notify Telegram on failure
|
||||||
if: env.FAILED == 'true'
|
|
||||||
run: |
|
|
||||||
# Read invalid files and format them for the message
|
|
||||||
INVALID_FILES=$(cat invalid_files.txt)
|
|
||||||
echo "INVALID_FILES<<EOF" >> $GITHUB_ENV
|
|
||||||
echo "$INVALID_FILES" >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Send Telegram message
|
|
||||||
if: env.FAILED == 'true'
|
if: env.FAILED == 'true'
|
||||||
uses: appleboy/telegram-action@master
|
uses: appleboy/telegram-action@master
|
||||||
with:
|
with:
|
||||||
@@ -67,6 +52,7 @@ jobs:
|
|||||||
message: |
|
message: |
|
||||||
❌ <b>Kubernetes validation failed!</b>
|
❌ <b>Kubernetes validation failed!</b>
|
||||||
|
|
||||||
Invalid files:
|
<b>Invalid files:</b>
|
||||||
${{ env.INVALID_FILES }}
|
<pre>${{ env.INVALID_FILES }}</pre>
|
||||||
<a href="https://gt.hexor.cy/${{ github.repository }}/actions/runs/${{ github.run_number }}">Check details</a>
|
|
||||||
|
🔗 <a href="https://gt.hexor.cy/${{ github.repository }}/actions/runs/${{ github.run_number }}">Details</a>
|
||||||
|
Reference in New Issue
Block a user