diff --git a/.forgejo/workflows/build-and-deploy.yaml b/.forgejo/workflows/build-and-deploy.yaml index 6e23112..90210f7 100644 --- a/.forgejo/workflows/build-and-deploy.yaml +++ b/.forgejo/workflows/build-and-deploy.yaml @@ -62,8 +62,8 @@ jobs: run: | COMMIT_HASH=$(echo ${GITHUB_SHA} | cut -c1-7) VERSION_TAG="${COMMIT_HASH}" - echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_OUTPUT - + echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_OUTPUT - name: Set up kubectl + - name: Set up kubectl run: | # Install kubectl @@ -72,6 +72,13 @@ jobs: curl -LO "https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/amd64/kubectl" chmod +x kubectl mv kubectl /usr/local/bin/ + + # Make sure we don't use any existing microk8s config + if [ -f /var/snap/microk8s/current/credentials/client.config ]; then + echo "Detected microk8s config - we'll use our own config instead" + # Backup any existing config and make sure it won't be used + [ -d $HOME/.kube ] && mv $HOME/.kube $HOME/.kube.bak + fi - name: Set up Helm run: | @@ -83,11 +90,14 @@ jobs: # Create kubeconfig using service account token - name: Configure kubeconfig from service account run: | - # Create kubeconfig using service account token - mkdir -p $HOME/.kube - cat > $HOME/.kube/config < $CONFIG_FILE <> $GITHUB_ENV + + # Verify the config is pointing to the correct server + echo "Checking kubectl configuration..." + KUBECTL_SERVER=$(KUBECONFIG=$CONFIG_FILE kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}') + echo "Kubectl is configured to use server: $KUBECTL_SERVER" + - name: Verify Kubernetes connectivity + run: | + # Test connectivity to the Kubernetes cluster + echo "Testing Kubernetes API connectivity..." + kubectl cluster-info + kubectl get nodes + - name: Deploy with Helm run: | # Deploy using Helm with service account authentication + echo "Deploying with Helm to server: $(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')" helm upgrade --install nextjs-slack-clone ${{ env.HELM_CHART_PATH }} \ --namespace ${{ env.NAMESPACE }} \ --set image.tag=${{ steps.generate_tag.outputs.VERSION_TAG }} \