Skip to content

Commit 4ade494

Browse files
authored
Merge pull request #40 from CGC-2026/hotfix/cloud-infra
yml changes
2 parents 37f6fba + dd3edae commit 4ade494

1 file changed

Lines changed: 67 additions & 5 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,71 @@ jobs:
9898
--query 'Command.CommandId' \
9999
--output text)
100100
101-
aws ssm get-command-invocation \
101+
- name: Wait for SSM command to finish
102+
run: |
103+
set -euo pipefail
104+
105+
COMMAND_ID='${{ steps.ssm_send.outputs.command_id }}'
106+
echo "Waiting on SSM CommandId: ${COMMAND_ID}"
107+
108+
for i in {1..80}; do
109+
STATUS=$(aws ssm get-command-invocation \
110+
--region "${AWS_REGION}" \
111+
--command-id "${COMMAND_ID}" \
112+
--instance-id "${EC2_INSTANCE_ID}" \
113+
--query 'Status' \
114+
--output text)
115+
116+
echo "SSM status: ${STATUS}"
117+
118+
case "$STATUS" in
119+
Pending|InProgress|Delayed)
120+
sleep 3
121+
;;
122+
Success)
123+
aws ssm get-command-invocation \
124+
--region "${AWS_REGION}" \
125+
--command-id "${COMMAND_ID}" \
126+
--instance-id "${EC2_INSTANCE_ID}" \
127+
--query '{Status:Status,ExitCode:ResponseCode,Stdout:StandardOutputContent,Stderr:StandardErrorContent}' \
128+
--output json
129+
exit 0
130+
;;
131+
*)
132+
aws ssm get-command-invocation \
133+
--region "${AWS_REGION}" \
134+
--command-id "${COMMAND_ID}" \
135+
--instance-id "${EC2_INSTANCE_ID}" \
136+
--query '{Status:Status,ExitCode:ResponseCode,Stdout:StandardOutputContent,Stderr:StandardErrorContent}' \
137+
--output json
138+
echo "SSM command failed with status: ${STATUS}" >&2
139+
exit 1
140+
;;
141+
esac
142+
done
143+
144+
echo "SSM command did not finish in time" >&2
145+
exit 1
146+
147+
- name: Verify health
148+
run: |
149+
set -euo pipefail
150+
151+
PUBLIC_IP=$(aws ec2 describe-instances \
102152
--region "${AWS_REGION}" \
103-
--command-id "${COMMAND_ID}" \
104-
--instance-id "${EC2_INSTANCE_ID}" \
105-
--query '{Status:Status,ExitCode:ResponseCode,Stdout:StandardOutputContent,Stderr:StandardErrorContent}' \
106-
--output json
153+
--instance-ids "${EC2_INSTANCE_ID}" \
154+
--query 'Reservations[0].Instances[0].PublicIpAddress' \
155+
--output text)
156+
157+
test "${PUBLIC_IP}" != "None"
158+
159+
for i in {1..20}; do
160+
if curl -fsS "${URL}" >/dev/null; then
161+
echo "Health check passed"
162+
exit 0
163+
fi
164+
echo "Health not ready yet (attempt $i/20) — retrying..."
165+
sleep 3
166+
done
167+
168+
echo "Health check failed"

0 commit comments

Comments
 (0)