Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
log.txt
.DS_Store
dist
src/emails/**/*.css
emails/node_modules
emails/temp
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ COPY . .
RUN npm install
RUN npm install dotenv --save
RUN npm test
RUN cd emails && npm install && npm run build && cd ..
CMD ["npm", "start"]
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ then
docker cp app:/opt/app/node_modules .
fi


# copy dist directory containing the built email template
docker cp app:/opt/app/emails/dist ./emails-dist
24 changes: 24 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ TOKEN_CACHE_TIME=$(eval "echo \$${ENV}_TOKEN_CACHE_TIME")
AUTH0_CLIENT_ID=$(eval "echo \$${ENV}_AUTH0_CLIENT_ID")
AUTH0_CLIENT_SECRET=$(eval "echo \$${ENV}_AUTH0_CLIENT_SECRET")

SENDGRID_API_KEY=$(eval "echo \$${ENV}_SENDGRID_API_KEY")
SENDGRID_TEMPLATE_ID=$(eval "echo \$${ENV}_SENDGRID_TEMPLATE_ID")
SENDGRID_VERSION_ID=$(eval "echo \$${ENV}_SENDGRID_VERSION_ID")

echo $APP_NAME

configure_aws_cli() {
Expand Down Expand Up @@ -293,7 +297,27 @@ check_service_status() {
echo "$servicestatus"
}

deploy_email_template() {

echo "Deploying email template"

template=`cat ./emails-dist/template.html`
jq -n --arg template "$template" \
'{"active":1,"html_content":$template}' > request-data.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gondzo Should we assume that it is always an active template version? Although, I don't see any use case of having id of an inactive template in the config, but I would like to avoid this just in case we have activated a different version in sendgrid than what we have configured in circle ci.



curl --request PATCH \
--url "https://api.sendgrid.com/v3/templates/$SENDGRID_TEMPLATE_ID/versions/$SENDGRID_VERSION_ID" \
--header "authorization: Bearer $SENDGRID_API_KEY" \
--header 'content-type: application/json' \
--data @request-data.txt

echo "Email template deployed"

}

configure_aws_cli
push_ecr_image
deploy_cluster
check_service_status
deploy_email_template
69 changes: 37 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.