@@ -104,11 +104,13 @@ jobs:
104104 --output text)
105105
106106 if [ -n "$TASK_ARN" ] && [ "$TASK_ARN" != "None" ]; then
107+ echo "--- Recent logs ---"
107108 aws logs tail /ecs/${{ vars.ECS_CLUSTER_NAME }} \
108109 --log-stream-name-prefix "ecs/api" \
109110 --since 30s \
110111 --format short \
111- --region ${{ vars.AWS_REGION }} 2>/dev/null | head -10 || true
112+ --region ${{ vars.AWS_REGION }} 2>/dev/null || true
113+ echo "---"
112114 fi
113115
114116 # Check if stable
@@ -147,11 +149,13 @@ jobs:
147149 --output text)
148150
149151 if [ -n "$TASK_ARN" ] && [ "$TASK_ARN" != "None" ]; then
152+ echo "--- Recent logs ---"
150153 aws logs tail /ecs/${{ vars.ECS_CLUSTER_NAME }} \
151154 --log-stream-name-prefix "ecs/worker" \
152155 --since 30s \
153156 --format short \
154- --region ${{ vars.AWS_REGION }} 2>/dev/null | head -10 || true
157+ --region ${{ vars.AWS_REGION }} 2>/dev/null || true
158+ echo "---"
155159 fi
156160
157161 # Check if stable
@@ -187,3 +191,34 @@ jobs:
187191 --region ${{ vars.AWS_REGION }} \
188192 --query 'services[0].{Status:status,Running:runningCount,Desired:desiredCount}' \
189193 --output table
194+
195+ - name : Get API endpoint
196+ run : |
197+ echo "=== API Endpoint ==="
198+ TASK_ARN=$(aws ecs list-tasks \
199+ --cluster ${{ vars.ECS_CLUSTER_NAME }} \
200+ --service-name ${{ vars.ECS_API_SERVICE_NAME }} \
201+ --region ${{ vars.AWS_REGION }} \
202+ --desired-status RUNNING \
203+ --query 'taskArns[0]' \
204+ --output text)
205+
206+ if [ -n "$TASK_ARN" ] && [ "$TASK_ARN" != "None" ]; then
207+ TASK_DETAILS=$(aws ecs describe-tasks \
208+ --cluster ${{ vars.ECS_CLUSTER_NAME }} \
209+ --tasks $TASK_ARN \
210+ --region ${{ vars.AWS_REGION }} \
211+ --query 'tasks[0].attachments[0].details')
212+
213+ PUBLIC_IP=$(echo $TASK_DETAILS | jq -r '.[] | select(.name=="networkInterfaceId") | .value' | xargs -I {} aws ec2 describe-network-interfaces --network-interface-ids {} --region ${{ vars.AWS_REGION }} --query 'NetworkInterfaces[0].Association.PublicIp' --output text)
214+
215+ if [ -n "$PUBLIC_IP" ] && [ "$PUBLIC_IP" != "None" ]; then
216+ echo "API is available at: http://$PUBLIC_IP"
217+ echo "Health check: http://$PUBLIC_IP/health"
218+ echo "Documentation: http://$PUBLIC_IP/docs"
219+ else
220+ echo "Could not retrieve public IP"
221+ fi
222+ else
223+ echo "No running API tasks found"
224+ fi
0 commit comments