forked from ab/homelab
Update .gitea/workflows/lint.yaml
This commit is contained in:
@ -9,36 +9,64 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: bmuschko/setup-kubeconform@v1
|
- uses: bmuschko/setup-kubeconform@v1
|
||||||
name: Setup Kubeconform
|
name: Setup Kubeconform
|
||||||
- name: Kubeconform
|
|
||||||
|
- name: Kubeconform validation
|
||||||
id: kubeconform
|
id: kubeconform
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
run: |
|
||||||
|
# Create a temporary file to store validation output
|
||||||
|
VALIDATION_OUTPUT=$(mktemp)
|
||||||
|
|
||||||
|
# Run kubeconform and capture output
|
||||||
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 \
|
||||||
-output text \
|
-verbose \
|
||||||
|
-output pretty \
|
||||||
-ignore-missing-schemas \
|
-ignore-missing-schemas \
|
||||||
-schema-location default \
|
-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' \
|
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
||||||
| tee kubeconform_output.txt
|
-schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT 2>&1
|
||||||
|
|
||||||
- name: Telegram notify on failure
|
# Store exit code
|
||||||
if: failure()
|
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<<EOF" >> $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
|
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: |
|
||||||
❌ CI failed for ${{ github.repository }}
|
🚨 Kubernetes manifest validation failed!
|
||||||
👤 By: ${{ github.actor }}
|
|
||||||
🧪 Commit: ${{ github.sha }}
|
|
||||||
🧾 Errors:
|
|
||||||
${{ steps.kubeconform.outputs.stdout }}
|
|
||||||
|
|
||||||
|
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 }}
|
Reference in New Issue
Block a user