From 01c85cbb7a4eb119f03d5153c95e174db87c5dff Mon Sep 17 00:00:00 2001 From: jasonwitty Date: Fri, 28 Nov 2025 12:41:34 -0800 Subject: [PATCH] Add deployment creation if it doesn't exist --- .gitea/workflows/build-and-deploy.yaml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build-and-deploy.yaml b/.gitea/workflows/build-and-deploy.yaml index f5e72fc..d90e4aa 100644 --- a/.gitea/workflows/build-and-deploy.yaml +++ b/.gitea/workflows/build-and-deploy.yaml @@ -89,12 +89,25 @@ jobs: run: | kubectl get deployment socktop-webterm -n default || echo "Deployment will be created" - - name: Update deployment image + - name: Check and create/update deployment run: | VERSION="${{ needs.build-and-push.outputs.version }}" - kubectl set image deployment/socktop-webterm \ - webterm=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \ - -n default + + # Check if deployment exists + if kubectl get deployment socktop-webterm -n default &> /dev/null; then + echo "Deployment exists, updating image..." + kubectl set image deployment/socktop-webterm \ + webterm=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \ + -n default + else + echo "Deployment does not exist, creating it..." + kubectl apply -f kubernetes/03-deployment.yaml + + # Update the image to the correct version + kubectl set image deployment/socktop-webterm \ + webterm=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \ + -n default + fi - name: Wait for rollout to complete run: |