Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdd3fbc

Browse files
Raymond JangRaymond Jang
authored andcommitted
CD workflow summary
1 parent f177aba commit cdd3fbc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

.github/workflows/cd.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,28 @@ jobs:
9595
service: ${{ env.ECS_SERVICE }}
9696
cluster: ${{ env.ECS_CLUSTER }}
9797
wait-for-service-stability: true
98-
# Output the app URL
98+
# Output the app URL
99+
- name: Set App IP
100+
id: set_app_ip
101+
run: |
102+
TASK_ARN=$(aws ecs list-tasks --cluster "${ECS_CLUSTER}" --service-name "${ECS_SERVICE}" --query 'taskArns[0]' --output text)
103+
TASK_DETAILS=$(aws ecs describe-tasks --cluster "${ECS_CLUSTER}" --task "${TASK_ARN}" --query 'tasks[0].attachments[0].details')
104+
ENI=$(echo $TASK_DETAILS | jq -r '.[] | select(.name=="networkInterfaceId").value')
105+
PUBLIC_IP=$(aws ec2 describe-network-interfaces --network-interface-ids "${ENI}" --query 'NetworkInterfaces[0].Association.PublicIp' --output text)
106+
echo "app_ip=$PUBLIC_IP" >> $GITHUB_OUTPUT
107+
108+
- name: Set App URL
109+
id: set_app_url
110+
run: |
111+
TARGET_GROUP_ARN=$(aws ecs describe-services --service "${ECS_SERVICE}" --cluster "${ECS_CLUSTER}" --query 'services[0].loadBalancers[0].targetGroupArn' --output text)
112+
LOAD_BALANCER_ARN=$(aws elbv2 describe-target-groups --target-group-arns $TARGET_GROUP_ARN --query 'TargetGroups[0].LoadBalancerArns[0]' --output text)
113+
APP_URL=$(aws elbv2 describe-load-balancers --load-balancer-arns $LOAD_BALANCER_ARN --query 'LoadBalancers[0].DNSName' --output text)
114+
echo "app_url=$APP_URL" >> $GITHUB_OUTPUT
115+
116+
- name: Summary
117+
id: summary
118+
run: |
119+
echo "" >> $GITHUB_STEP_SUMMARY # this is a blank line
120+
echo "## ECS Task" >> $GITHUB_STEP_SUMMARY
121+
echo "* App URL: http://${{ steps.set_app_url.outputs.APP_URL }}" >> $GITHUB_STEP_SUMMARY
122+
echo "" >> $GITHUB_STEP_SUMMARY # this is a blank line

0 commit comments

Comments
 (0)