Skip to content

Commit 1d6ed05

Browse files
committed
dded deployment code for backend-springboot
1 parent 61a4424 commit 1d6ed05

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,35 @@ jobs:
105105
ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/back-end
106106
docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/aws-integration:$IMAGE_TAG $ECR_URI:$IMAGE_TAG
107107
docker push $ECR_URI:$IMAGE_TAG
108+
# --- Register new task definition for backend ---
109+
- name: Register new task definition with updated image (backend)
110+
run: |
111+
IMAGE_TAG=v1.0.${GITHUB_RUN_NUMBER}
112+
ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/back-end
113+
114+
# Get current task definition JSON
115+
TASK_DEF_JSON=$(aws ecs describe-task-definition \
116+
--task-definition spring-boot-td \
117+
--query 'taskDefinition' \
118+
--output json)
119+
120+
# Update the container image
121+
NEW_TASK_DEF=$(echo $TASK_DEF_JSON | jq --arg IMAGE "$ECR_URI:$IMAGE_TAG" \
122+
'.containerDefinitions[0].image=$IMAGE | del(.status,.revision,.taskDefinitionArn,.requiresAttributes,.compatibilities,.registeredAt,.registeredBy)')
123+
124+
# Register new task definition revision
125+
aws ecs register-task-definition \
126+
--cli-input-json "$NEW_TASK_DEF"
127+
128+
# --- Update ECS service to use new task definition ---
129+
- name: Update ECS service (backend)
130+
run: |
131+
# Get the new revision number
132+
NEW_REV=$(aws ecs describe-task-definition --task-definition spring-boot-td | jq '.taskDefinition.revision')
133+
134+
# Force ECS service to use the new task definition
135+
aws ecs update-service \
136+
--cluster spring-boot-react-aws-integration \
137+
--service spring-boot-service \
138+
--task-definition spring-boot-td:$NEW_REV \
139+
--force-new-deployment

0 commit comments

Comments
 (0)