Fail fast with a clear error when KUBECONFIG secret is missing
All checks were successful
Validate and Deploy to K3s / validate (push) Successful in 18s
Validate and Deploy to K3s / deploy (push) Successful in 31s

An unset secret expands to empty, base64 -d writes a zero-byte kubeconfig,
and kubectl falls back to localhost:8080 with a misleading connection
error. Guard both jobs and echo the current context after configuring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jasonwitty 2026-07-26 03:28:46 -07:00
parent fe72f1e85a
commit f89e312b05

View File

@ -32,9 +32,14 @@ jobs:
- name: Configure kubectl - name: Configure kubectl
run: | run: |
if [ -z "${{ secrets.KUBECONFIG }}" ]; then
echo "::error::Repo Actions secret KUBECONFIG is not set (Settings -> Actions -> Secrets). Without it kubectl silently falls back to localhost:8080."
exit 1
fi
mkdir -p $HOME/.kube mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
chmod 600 $HOME/.kube/config chmod 600 $HOME/.kube/config
kubectl config current-context
- name: Server-side dry-run of full kustomization - name: Server-side dry-run of full kustomization
run: | run: |
@ -65,9 +70,14 @@ jobs:
- name: Configure kubectl - name: Configure kubectl
run: | run: |
if [ -z "${{ secrets.KUBECONFIG }}" ]; then
echo "::error::Repo Actions secret KUBECONFIG is not set (Settings -> Actions -> Secrets). Without it kubectl silently falls back to localhost:8080."
exit 1
fi
mkdir -p $HOME/.kube mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
chmod 600 $HOME/.kube/config chmod 600 $HOME/.kube/config
kubectl config current-context
- name: Apply kustomization - name: Apply kustomization
run: | run: |