fix(cd): use printf for robust KUBECONFIG writing and add diagnostics
Some checks failed
CI Pipeline / Frontend Lint, Test & Build (push) Has been cancelled
CI Pipeline / Infrastructure Validation (push) Has been cancelled
CI Pipeline / Backend Build & Test (push) Has been cancelled

This commit is contained in:
WorkClub Automation
2026-03-10 20:35:12 +01:00
parent df625f3b3a
commit b1c351e936

View File

@@ -55,12 +55,23 @@ jobs:
mkdir -p $HOME/.kube
if echo "${{ secrets.KUBECONFIG }}" | grep -q "apiVersion"; then
echo "Detected plain text KUBECONFIG"
echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config
printf '%s' "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config
else
echo "Detected base64 KUBECONFIG"
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
printf '%s' "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
fi
chmod 600 $HOME/.kube/config
# Diagnostics
echo "Kubeconfig size: $(wc -c < $HOME/.kube/config) bytes"
if ! grep -q "current-context" $HOME/.kube/config; then
echo "Warning: current-context missing, attempting to fix..."
FIRST_CONTEXT=$(kubectl config get-contexts -o name | head -n 1)
if [ -n "$FIRST_CONTEXT" ]; then
kubectl config use-context "$FIRST_CONTEXT"
fi
fi
kubectl config view --minify # Verification of context
kubectl apply -k infra/k8s/overlays/dev
env: