Skip to content

Commit ffc5212

Browse files
committed
Kubernetes: Improve validation results handling in KubeCheck workflow with enhanced output and artifact upload
Signed-off-by: NotHarshhaa <[email protected]>
1 parent 5d1833b commit ffc5212

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: .github/workflows/kubecheck.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
RESULTS=""
6161
PASS_COUNT=0
6262
FAIL_COUNT=0
63-
for file in $(cat changed_yamls.txt); do
63+
while IFS= read -r file; do
6464
output=$(kubeconform -strict -verbose "$file" 2>&1)
6565
if echo "$output" | grep -q "PASS"; then
6666
emoji="✅"
@@ -70,7 +70,7 @@ jobs:
7070
FAIL_COUNT=$((FAIL_COUNT + 1))
7171
fi
7272
RESULTS="${RESULTS}${emoji} \`${file}\`\n${output}\n\n"
73-
done
73+
done < changed_yamls.txt
7474
7575
SUMMARY="✅ Passed: ${PASS_COUNT} | ❌ Failed: ${FAIL_COUNT}"
7676
echo "$RESULTS" > validation_output.txt
@@ -81,13 +81,22 @@ jobs:
8181
8282
echo "summary=${SUMMARY}" >> $GITHUB_OUTPUT
8383
84+
echo -e "$RESULTS"
85+
8486
- name: Set summary for skipped validation
8587
if: steps.detect_changes.outputs.changed == 'false'
8688
id: kubeval_skip
8789
run: |
8890
echo "summary=✅ No Kubernetes YAML files changed. Skipped validation." >> $GITHUB_OUTPUT
8991
echo "results=" >> $GITHUB_OUTPUT
9092
93+
- name: Upload validation results
94+
if: always()
95+
uses: actions/upload-artifact@v3
96+
with:
97+
name: validation-results
98+
path: validation_output.txt
99+
91100
- name: Fail if any errors
92101
if: steps.detect_changes.outputs.changed == 'true'
93102
run: |
@@ -101,7 +110,11 @@ jobs:
101110
needs: [fetch_commit_info, validate_kubeconform]
102111
if: always()
103112
steps:
113+
- name: Checkout code
114+
uses: actions/checkout@v3
115+
104116
- name: Comment on commit
117+
working-directory: ${{ github.workspace }}
105118
env:
106119
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
107120
SHA: ${{ needs.fetch_commit_info.outputs.sha }}

0 commit comments

Comments
 (0)