Skip to content

Commit

Permalink
feat: add script to populate value
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin9foong committed Jan 3, 2025
1 parent 915afa6 commit 6a4e753
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ jobs:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
environment-variables: |
ENV_TYPE=${{ contains(env.CURRENT_ENV, 'staging') && 'staging' || contains(env.CURRENT_ENV, 'prod') && 'prod' || contains(env.CURRENT_ENV, 'uat') && 'uat' || env.CURRENT_ENV }}
ENV_SITE_NAME=${{ env.CURRENT_ENV }}
- name: Deploy Amazon ECS task definition
env: # For ECS deployment
Expand Down
1 change: 1 addition & 0 deletions ecs-task-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
"name": "formsg-app",
"essential": true,
"command": "/bin/sh -c \"./generate-env-from-ecs-params.sh && npm start\"",
"portMappings": [
{ "containerPort": 3000 }
]
Expand Down
31 changes: 31 additions & 0 deletions generate-env-from-ecs-params.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
TARGET_DIR=/etc/formsg
ENV_TYPE=$ENV_TYPE
ENV_SITE_NAME=$ENV_SITE_NAME

# create target dir if not exist
echo "Checking if ${TARGET_DIR} exists..."
if [ ! -d ${TARGET_DIR} ]; then
echo "Creating directory ${TARGET_DIR} ..."
mkdir -p ${TARGET_DIR}
if [ $? -ne 0 ]; then
echo 'ERROR: Directory creation failed!'
exit 1
fi
else
echo "Directory ${TARGET_DIR} already exists!"
fi

echo "${ENV_TYPE}-general" > $TARGET_DIR/.env
echo "${ENV_TYPE}-captcha" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-turnstile" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-ga" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-intranet" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-sms" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-ndi" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-verified-fields" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-webhook-verified-content" >> $TARGET_DIR/.env
echo "${ENV_TYPE}-wogaa" >> $TARGET_DIR/.env
echo "${ENV_SITE_NAME}-sgid" >> $TARGET_DIR/.env
echo "${ENV_SITE_NAME}-payment" >> $TARGET_DIR/.env
echo "${ENV_SITE_NAME}-cron-payment" >> $TARGET_DIR/.env
echo "${ENV_SITE_NAME}-openai" >> $TARGET_DIR/.env

0 comments on commit 6a4e753

Please sign in to comment.