@@ -99,41 +99,40 @@ jobs:
9999 with :
100100 registry-type : public
101101
102- - name : Tag and push to ECR Public
102+ - name : Tag and push to ECR Public (backend)
103103 run : |
104104 IMAGE_TAG=v1.0.${{ github.run_number }}
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 ---
108+
109109 - name : Register new task definition with updated image (backend)
110110 run : |
111111 IMAGE_TAG=v1.0.${GITHUB_RUN_NUMBER}
112112 ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/back-end
113113
114114 # Get current task definition JSON
115115 TASK_DEF_JSON=$(aws ecs describe-task-definition \
116- --task-definition spring-boot-td \
116+ --task-definition ${{ secrets.BACKEND_TASK_DEF }} \
117117 --query 'taskDefinition' \
118118 --output json)
119119
120120 # Update the container image
121121 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)')
122+ " .containerDefinitions[] | select(.name==\"${{ secrets.BACKEND_CONTAINER }}\") | . image=\ $IMAGE | del(.status,.revision,.taskDefinitionArn,.requiresAttributes,.compatibilities,.registeredAt,.registeredBy)" | jq -s '.[0] ')
123123
124124 # Register new task definition revision
125125 aws ecs register-task-definition \
126126 --cli-input-json "$NEW_TASK_DEF"
127127
128- # --- Update ECS service to use new task definition ---
129128 - name : Update ECS service (backend)
130129 run : |
131130 # Get the new revision number
132- NEW_REV=$(aws ecs describe-task-definition --task-definition spring-boot-td | jq '.taskDefinition.revision')
131+ NEW_REV=$(aws ecs describe-task-definition --task-definition ${{ secrets.BACKEND_TASK_DEF }} | jq '.taskDefinition.revision')
133132
134133 # Force ECS service to use the new task definition
135134 aws ecs update-service \
136- --cluster spring-boot-react-aws-integration \
137- --service spring-boot-service \
138- --task-definition spring-boot-td :$NEW_REV \
135+ --cluster ${{ secrets.CLUSTER_NAME }} \
136+ --service ${{ secrets.BACKEND_SERVICE }} \
137+ --task-definition ${{ secrets.BACKEND_TASK_DEF }} :$NEW_REV \
139138 --force-new-deployment
0 commit comments