ci: handle errors in helm templating
renovate / renovate (push) Successful in 11m51s

This commit is contained in:
2026-05-17 22:11:14 -05:00
parent 9f162d6d8e
commit 62f3b61e9d
2 changed files with 19 additions and 2 deletions
+18 -2
View File
@@ -250,6 +250,8 @@ jobs:
echo ">> Rendering Manifests ..."
EXIT_CODE=0
render_chart() {
local DIR="$1"
local CHART_PATH="${MAIN_DIR}/clusters/${CLUSTER}/helm/${DIR}"
@@ -283,10 +285,17 @@ jobs:
echo ">> Formating rendered template ..."
local TEMPLATE
TEMPLATE=$(helm template "${CHART_NAME}" ./ --namespace "${NAMESPACE}" --include-crds --dry-run=server --api-versions "gateway.networking.k8s.io/v1/HTTPRoute,monitoring.coreos.com/v1,monitoring.coreos.com/v1/ServiceMonitor")
if ! TEMPLATE=$(helm template "${CHART_NAME}" ./ --namespace "${NAMESPACE}" --include-crds --dry-run=server --api-versions "gateway.networking.k8s.io/v1/HTTPRoute,monitoring.coreos.com/v1,monitoring.coreos.com/v1/ServiceMonitor"); then
echo "${DIR}" > "${MAIN_DIR}/.failed_chart_${DIR}"
return 1
fi
# Format and split rendered template
echo "${TEMPLATE}" | yq '... comments=""' | yq 'select(. != null)' | yq -s '"'"${OUTPUT_FOLDER}"'" + .kind + "-" + .metadata.name + ".yaml"'
set -o pipefail
if ! echo "${TEMPLATE}" | yq '... comments=""' | yq 'select(. != null)' | yq -s '"'"${OUTPUT_FOLDER}"'" + .kind + "-" + .metadata.name + ".yaml"'; then
echo "${DIR}" > "${MAIN_DIR}/.failed_chart_${DIR}"
return 1
fi
# Strip comments again to ensure formatting correctness
for file in "$OUTPUT_FOLDER"/*; do
@@ -316,9 +325,16 @@ jobs:
done | xargs -P 5 -I {} bash -c 'OUT=$(render_chart "$@" 2>&1); printf "%s\n" "$OUT"' _ {}
if ls .failed_chart_* 1> /dev/null 2>&1; then
EXIT_CODE=1
rm -f .failed_chart_*
fi
echo ""
echo "----"
exit $EXIT_CODE
- name: Check for Changes
id: check-changes
if: steps.check-dir-changes.outputs.changes-detected == 'true'