Skip to content

Commit 61a4424

Browse files
committed
added deployment code for front-end
1 parent ea6059b commit 61a4424

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/front-end.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,34 @@ jobs:
8484
ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/front-end
8585
docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/frontend-aws-integration:$IMAGE_TAG $ECR_URI:$IMAGE_TAG
8686
docker push $ECR_URI:$IMAGE_TAG
87+
88+
- name: Register new task definition with updated image
89+
run: |
90+
IMAGE_TAG=v1.0.${GITHUB_RUN_NUMBER}
91+
ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/front-end
92+
93+
# Get current task definition JSON
94+
TASK_DEF_JSON=$(aws ecs describe-task-definition \
95+
--task-definition front-end-td \
96+
--query 'taskDefinition' \
97+
--output json)
98+
99+
# Update the container image
100+
NEW_TASK_DEF=$(echo $TASK_DEF_JSON | jq --arg IMAGE "$ECR_URI:$IMAGE_TAG" \
101+
'.containerDefinitions[0].image=$IMAGE | del(.status,.revision,.taskDefinitionArn,.requiresAttributes,.compatibilities,.registeredAt,.registeredBy)')
102+
103+
# Register new task definition revision
104+
aws ecs register-task-definition \
105+
--cli-input-json "$NEW_TASK_DEF"
106+
107+
- name: Update ECS service
108+
run: |
109+
# Get the new revision number
110+
NEW_REV=$(aws ecs describe-task-definition --task-definition front-end-td | jq '.taskDefinition.revision')
111+
112+
# Force ECS service to use the new task definition
113+
aws ecs update-service \
114+
--cluster spring-boot-react-aws-integration \
115+
--service front-end-service \
116+
--task-definition front-end-td:$NEW_REV \
117+
--force-new-deployment

0 commit comments

Comments
 (0)