Skip to content

Commit

Permalink
fix attempt: retry deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomlam committed Jun 8, 2024
1 parent 68a6cad commit dc42b18
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lightsail-mgmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ jobs:
sudo chmod +x /usr/local/bin/lightsailctl
- name: "Extract branch name"
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: "Install waitForLightsail.sh"
run: |
echo "https://raw.githubusercontent.com/$GITHUB_REPOSITORY/${{ steps.extract_branch.outputs.branch }}/.github/workflows/waitForLightsail.sh"
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ on:
type: boolean
default: true
deploy_image:
description: "Deploy image"
description: "Deploy built image or last deployment"
required: true
type: boolean
default: true
Expand Down Expand Up @@ -144,6 +144,7 @@ jobs:
"ENV": "PROD",
"BUILD_DATE": "$BUILD_DATE",
"BUILD_FOLDER": "${{ inputs.dockerfile_folder }}",
"GIT_BRANCH": "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}",
"GIT_SHA": "${{ github.sha }}"
},
"ports": {
Expand All @@ -167,10 +168,18 @@ jobs:
echo "$CONFIG_TEMPLATE" | BUILD_DATE=$(date +%Y-%m-%d-%T%z) envsubst > config.json
cat config.json
echo "Creating new deployment"
aws lightsail create-container-service-deployment --cli-input-json file://config.json
sleep 10
./.github/workflows/waitForLightsail.sh deployment
for ((i = 0 ; i < ${DEPLOY_RETRIES:=3} ; i++ )); do
echo "## Deploy attempt $((i+1)) of $DEPLOY_RETRIES"
date
echo "Creating new deployment"
aws lightsail create-container-service-deployment --cli-input-json file://config.json
sleep 10
if ./.github/workflows/waitForLightsail.sh deployment; then
echo "Success"
break;
fi
done
date
# TODO: warm up vector DB on startup
2 changes: 1 addition & 1 deletion 05-assistive-chatbot/chatbot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def healthcheck(request: Request):
build_date = os.environ.get("BUILD_DATE", "")

logger.info("Returning: Healthy %s %s", build_date, git_sha)
return HTMLResponse(f"Healthy {build_date} {git_sha}")
return HTMLResponse(f"Healthy {git_sha} built at {build_date}")


if __name__ == "__main__":
Expand Down

0 comments on commit dc42b18

Please sign in to comment.