diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 7b83e17..fb2463a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -118,7 +118,19 @@ jobs: mkdir -p ~/.kube echo "🔍 Debugging KUBECTLSECRET..." - echo "Secret length: ${#KUBECTLSECRET}" + SECRET_LENGTH=${#KUBECTLSECRET} + echo "Secret length: $SECRET_LENGTH" + + # Check if secret is empty + if [ "$SECRET_LENGTH" -eq 0 ]; then + echo "❌ ERROR: KUBECTLSECRET is empty!" + echo "Please configure the KUBECTLSECRET in Gitea repository secrets." + echo "Steps:" + echo "1. Run: cat ~/.kube/config | base64 -w 0" + echo "2. Copy the output" + echo "3. Add it as 'KUBECTLSECRET' secret in Gitea" + exit 1 + fi # Try to decode as base64 first, if that fails, use as plain text if echo "${{ secrets.KUBECTLSECRET }}" | base64 -d > ~/.kube/config 2>/dev/null; then @@ -130,6 +142,14 @@ jobs: echo "📁 kubeconfig created at ~/.kube/config" chmod 600 ~/.kube/config + + # Validate kubeconfig + if [ ! -s ~/.kube/config ]; then + echo "❌ ERROR: kubeconfig file is empty!" + exit 1 + fi + + echo "✅ kubeconfig validation passed" - name: Test kubectl connection run: | @@ -322,7 +342,19 @@ jobs: mkdir -p ~/.kube echo "🔍 Debugging KUBECTLSECRET..." - echo "Secret length: ${#KUBECTLSECRET}" + SECRET_LENGTH=${#KUBECTLSECRET} + echo "Secret length: $SECRET_LENGTH" + + # Check if secret is empty + if [ "$SECRET_LENGTH" -eq 0 ]; then + echo "❌ ERROR: KUBECTLSECRET is empty!" + echo "Please configure the KUBECTLSECRET in Gitea repository secrets." + echo "Steps:" + echo "1. Run: cat ~/.kube/config | base64 -w 0" + echo "2. Copy the output" + echo "3. Add it as 'KUBECTLSECRET' secret in Gitea" + exit 1 + fi # Try to decode as base64 first, if that fails, use as plain text if echo "${{ secrets.KUBECTLSECRET }}" | base64 -d > ~/.kube/config 2>/dev/null; then @@ -334,6 +366,14 @@ jobs: echo "📁 kubeconfig created at ~/.kube/config" chmod 600 ~/.kube/config + + # Validate kubeconfig + if [ ! -s ~/.kube/config ]; then + echo "❌ ERROR: kubeconfig file is empty!" + exit 1 + fi + + echo "✅ kubeconfig validation passed" - name: Test kubectl connection run: |