Skip to content

Commit ff3c1b0

Browse files
committed
fix build
1 parent 5d37c2c commit ff3c1b0

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,22 @@ jobs:
6767
6868
- name: Deploy to EKS
6969
run: |
70+
# Set deployment name
71+
DEPLOYMENT_NAME=${{ vars.DEPLOYMENT_NAME }}
72+
7073
# Check if the deployment exists
71-
kubectl get deployment ${{ vars.DEPLOYMENT_NAME }} -n default &> /dev/null
72-
if [ $? -ne 0 ]; then
73-
echo "Deployment does not exist. Creating..."
74-
kubectl create deployment ${{ vars.DEPLOYMENT_NAME }} --image=${{ vars.IMAGE_REGISTRY }}:$LATEST_SHA -n default
74+
DEPLOYMENT_EXISTS=$(kubectl get deployment $DEPLOYMENT_NAME -n default --ignore-not-found)
75+
76+
if [ -z "$DEPLOYMENT_EXISTS" ]; then
77+
echo "Deployment does not exist. Creating deployment."
78+
kubectl create deployment $DEPLOYMENT_NAME --image=${{ vars.IMAGE_REGISTRY }}:$LATEST_SHA -n default
7579
else
7680
echo "Deployment exists. Updating..."
77-
kubectl set image deployment/${{ vars.DEPLOYMENT_NAME }} ${{ vars.DEPLOYMENT_NAME }}=${{ vars.IMAGE_REGISTRY }}:$LATEST_SHA -n default
78-
fi
7981
80-
- name: Verify Deployment
81-
run: |
82-
kubectl rollout status deployment/${{ vars.DEPLOYMENT_NAME }} -n default
82+
# Automatically detect the container name from the deployment
83+
CONTAINER_NAME=$(kubectl get deployment $DEPLOYMENT_NAME -n default -o jsonpath='{.spec.template.spec.containers[0].name}')
84+
85+
# Use the detected container name to update the image
86+
echo "Container name detected: $CONTAINER_NAME"
87+
kubectl set image deployment/$DEPLOYMENT_NAME $CONTAINER_NAME=${{ vars.IMAGE_REGISTRY }}:$LATEST_SHA -n default
88+
fi

0 commit comments

Comments
 (0)