Skip to content

Commit d63ef62

Browse files
authored
Merge pull request #1946 from ChildMindInstitute/release/2025.09.2
Release 2025.09.2
2 parents 8cb25cd + 5a8e5fd commit d63ef62

32 files changed

Lines changed: 573 additions & 212 deletions

.github/workflows/_build.yaml

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Build
33
on:
44
workflow_call:
55
inputs:
6+
env-name:
7+
required: true
8+
type: string
69
tag-name:
710
description: Docker tag to create
811
required: false
@@ -30,16 +33,23 @@ env:
3033
BUILD_NUMBER: ${{github.run_id}}
3134

3235
OUT_DIR: ./out
33-
AWS_REGION : "us-east-1"
3436

35-
ECR_REPO: 917902836630.dkr.ecr.us-east-1.amazonaws.com/api-server
36-
ECR_ADDRESS: 917902836630.dkr.ecr.us-east-1.amazonaws.com
37+
# ECR_REPO: 917902836630.dkr.ecr.us-east-1.amazonaws.com/api-server
38+
# ECR_ADDRESS: 917902836630.dkr.ecr.us-east-1.amazonaws.com
3739

3840

3941
jobs:
42+
setup-vars:
43+
uses: ./.github/workflows/_setup.yaml
44+
with:
45+
env-name: ${{ inputs.env-name }}
46+
4047
build:
4148
name: Docker Build and Push
4249
runs-on: ubuntu-latest
50+
needs: setup-vars
51+
env:
52+
AWS_REGION: ${{ needs.setup-vars.outputs.region }}
4353
outputs:
4454
image-name: ${{ steps.sha.outputs.IMAGE_NAME }}
4555
image-sha: ${{ steps.sha.outputs.SHORT_SHA }}
@@ -55,27 +65,21 @@ jobs:
5565
- name: configure aws credentials
5666
uses: aws-actions/configure-aws-credentials@v4
5767
with:
58-
role-to-assume: arn:aws:iam::917902836630:role/cmiml-devops-oidc-github-role
68+
role-to-assume: ${{ needs.setup-vars.outputs.devops-role }}
5969
role-session-name: gha-oidc-runner
60-
aws-region: ${{ env.AWS_REGION }}
70+
aws-region: ${{ needs.setup-vars.outputs.region }}
6171

62-
- name: Get secrets by name and by ARN
63-
uses: aws-actions/aws-secretsmanager-get-secrets@v2
64-
with:
65-
parse-json-secrets: true
66-
secret-ids: |
67-
,cmiml-devops
6872

6973
- name: Login to ECR
7074
run: |
71-
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ env.ECR_ADDRESS }}
75+
aws ecr get-login-password --region ${{ needs.setup-vars.outputs.region }} | docker login --username AWS --password-stdin ${{ needs.setup-vars.outputs.ecr-repo }}
7276
7377
- name: Generate short sha
7478
id: sha
7579
run: |
7680
SHORT_SHA=$(git rev-parse --short HEAD)
7781
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_OUTPUT
78-
echo "IMAGE_NAME=${ECR_REPO}:${SHORT_SHA}" >> "$GITHUB_OUTPUT"
82+
echo "IMAGE_NAME=${{ needs.setup-vars.outputs.ecr-repo }}/api-server:${SHORT_SHA}" >> "$GITHUB_OUTPUT"
7983
8084
- name: Build and push
8185
uses: docker/build-push-action@v6
@@ -87,33 +91,10 @@ jobs:
8791
PIPENV_EXTRA_ARGS=--dev
8892
DD_GIT_REPOSITORY_URL=${{ github.repositoryUrl }}
8993
DD_GIT_COMMIT_SHA=${{ github.sha }}
90-
cache-to: mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=${{ env.ECR_REPO }}:cache
91-
cache-from: type=registry,ref=${{ env.ECR_REPO }}:cache
94+
cache-to: mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=${{ needs.setup-vars.outputs.ecr-repo }}/api-server:cache
95+
cache-from: type=registry,ref=${{ needs.setup-vars.outputs.ecr-repo }}/api-server:cache
9296
tags: |
93-
${{ env.ECR_REPO }}:${{ inputs.tag-name }}
94-
${{ env.ECR_REPO }}:${{ steps.sha.outputs.SHORT_SHA }}
97+
${{ needs.setup-vars.outputs.ecr-repo }}/api-server:${{ inputs.tag-name }}
98+
${{ needs.setup-vars.outputs.ecr-repo }}/api-server:${{ steps.sha.outputs.SHORT_SHA }}
9599
platforms: linux/amd64,linux/arm64
96100

97-
# # TODO What is this used for? Leftover artifact from Jenkins
98-
# - name: Extract Jira ticket numbers from commit message
99-
# run: |
100-
# tickets=$(git log -1 --pretty=%B | grep -io 'M2-[0-9]\+' | tr '[:lower:]' '[:upper:]' | sort | uniq | tr '\n' ' ')
101-
# if [ -z "$tickets" ]; then
102-
# echo "No Jira tickets found in the latest commit message."
103-
# else
104-
# echo "Jira ticket numbers found: ${tickets}"
105-
# if [ "${GITHUB_BRANCH_OR_TAG}" != "develop" ]; then
106-
# echo "Skipping saving Jira ticket numbers to a file because the branch is not develop"
107-
# else
108-
# file="jira-tickets.json"
109-
# echo "{ \"issues\": $(echo "${tickets}" | jq -R -s -c 'split(" ")[:-1]') }" > "${file}"
110-
# echo "Jira ticket numbers saved to ${file}"
111-
# fi
112-
# fi
113-
#
114-
# - name: Upload artifacts
115-
# uses: actions/upload-artifact@v4
116-
# with:
117-
# name: build-artifacts
118-
# path: |
119-
# ${GITHUB_REPO_NAME}/${OUT_DIR}/jira-tickets.json

.github/workflows/_deploy.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
SLACK_COLOR: failure
112112
SLACK_WEBHOOK: ${{ secrets.slack-webhook }}
113113
MSG_MINIMAL: actions url
114-
SLACK_TITLE: Deployment to ${{ inputs.env-name }} environment
114+
SLACK_TITLE: Backend deployed to ${{ inputs.env-name }}
115115
SLACK_MESSAGE: '🚨 Error when executing deployment!'
116116

117117
on-deploy-success:
@@ -120,7 +120,15 @@ jobs:
120120
needs:
121121
- deploy
122122
steps:
123-
- uses: actions/checkout@v4
123+
- name: "Send Slack message on success"
124+
uses: rtCamp/action-slack-notify@v2
125+
env:
126+
SLACK_COLOR: success
127+
SLACK_WEBHOOK: ${{ secrets.slack-webhook }}
128+
MSG_MINIMAL: actions url
129+
SLACK_TITLE: Backend deployed to ${{ inputs.env-name }}
130+
SLACK_MESSAGE: '🚀 Deployment was successful. Version: *${{ inputs.image-tag }}*'
131+
124132
- name: configure aws credentials
125133
uses: aws-actions/configure-aws-credentials@v4
126134
with:
@@ -135,11 +143,4 @@ jobs:
135143
--type "String" \
136144
--overwrite
137145
138-
- name: "Send Slack message on success"
139-
uses: rtCamp/action-slack-notify@v2
140-
env:
141-
SLACK_COLOR: success
142-
SLACK_WEBHOOK: ${{ secrets.slack-webhook }}
143-
MSG_MINIMAL: actions url
144-
SLACK_TITLE: Deployment to ${{ inputs.env-name }} environment
145-
SLACK_MESSAGE: '🚀 Deployment was successful. Version: *${{ inputs.image-tag }}*'
146+

.github/workflows/_setup.yaml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ on:
33
workflow_call:
44
outputs:
55
role:
6-
description: Role name
6+
description: Environment Role ARN
77
value: ${{ jobs.setup-vars.outputs.role }}
8+
devops-role:
9+
description: Environment Devops Role ARN
10+
value: ${{ jobs.setup-vars.outputs.devops-role }}
811
region:
912
description: AWS Region name
1013
value: ${{ jobs.setup-vars.outputs.region }}
@@ -46,7 +49,7 @@ jobs:
4649
"prod")
4750
echo 'role=arn:aws:iam::410431445687:role/cmiml-prod-oidc-github-role' >> "$GITHUB_OUTPUT"
4851
;;
49-
"prod-dr")
52+
"prod-dr-us-west-2")
5053
echo 'role=arn:aws:iam::973422231492:role/cmiml-dr-oidc-github-role' >> "$GITHUB_OUTPUT"
5154
;;
5255
*)
@@ -59,7 +62,7 @@ jobs:
5962
run: |
6063
ENV_NAME="${{ inputs.env-name }}"
6164
case "$ENV_NAME" in
62-
"prod-dr")
65+
"prod-dr-us-west-2")
6366
echo "region=us-west-2" >> "$GITHUB_OUTPUT"
6467
;;
6568
*)
@@ -71,7 +74,7 @@ jobs:
7174
run: |
7275
ENV_NAME="${{ inputs.env-name }}"
7376
case "$ENV_NAME" in
74-
"prod-dr")
77+
"prod-dr-us-west-2")
7578
echo "cluster=prod-dr-us-west-2" >> "$GITHUB_OUTPUT"
7679
;;
7780
*)
@@ -83,16 +86,30 @@ jobs:
8386
run: |
8487
ENV_NAME="${{ inputs.env-name }}"
8588
case "$ENV_NAME" in
86-
"prod-dr")
87-
echo "repo=973422231492.dkr.ecr.us-east-1.amazonaws.com" >> "$GITHUB_OUTPUT"
89+
"prod-dr-us-west-2")
90+
echo "repo=973422231492.dkr.ecr.us-west-2.amazonaws.com" >> "$GITHUB_OUTPUT"
8891
;;
8992
*)
9093
echo "repo=917902836630.dkr.ecr.us-east-1.amazonaws.com" >> "$GITHUB_OUTPUT"
9194
;;
9295
esac
9396
97+
- name: Map env to devops role
98+
id: devops-role
99+
run: |
100+
ENV_NAME="${{ inputs.env-name }}"
101+
case "$ENV_NAME" in
102+
"prod-dr-us-west-2")
103+
echo "role=arn:aws:iam::973422231492:role/cmiml-devops-oidc-github-role" >> "$GITHUB_OUTPUT"
104+
;;
105+
*)
106+
echo "role=arn:aws:iam::917902836630:role/cmiml-devops-oidc-github-role" >> "$GITHUB_OUTPUT"
107+
;;
108+
esac
109+
94110
outputs:
95111
role: ${{ steps.role.outputs.role }}
96112
region: ${{ steps.region.outputs.region }}
97113
cluster: ${{ steps.cluster.outputs.cluster }}
98114
ecr-repo: ${{ steps.ecr.outputs.repo }}
115+
devops-role: ${{ steps.devops-role.outputs.role }}

.github/workflows/run_build_deploy_dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
uses: ./.github/workflows/_build.yaml
3939
with:
4040
tag-name: ${{ needs.version.outputs.short-sha }}
41+
env-name: dev
4142

4243
migrations:
4344
needs: [version, build]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build and Deploy to DR
2+
3+
on:
4+
release:
5+
types:
6+
- released
7+
workflow_dispatch:
8+
inputs:
9+
target-ref:
10+
description: The tag to use
11+
required: true
12+
type: string
13+
14+
15+
concurrency:
16+
cancel-in-progress: false
17+
group: api-build-deploy-dr
18+
19+
permissions:
20+
id-token: write
21+
contents: read
22+
issues: write
23+
24+
jobs:
25+
ref:
26+
name: Get target ref
27+
runs-on: ubuntu-latest
28+
outputs:
29+
target-ref: ${{ steps.ref.outputs.ref }}
30+
steps:
31+
- id: ref
32+
name: Select Ref
33+
run: |
34+
TARGET_REF="${{ github.event.inputs.target-ref }}"
35+
# Use shell parameter expansion to provide a default value if input is unset or empty
36+
# github.ref_name will be used if the input is not provided or empty
37+
# Remove "refs/heads/" or "refs/tags/" if present in github.ref_name
38+
TARGET_REF=${TARGET_REF:-$(echo "${{ github.event.release.tag_name }}" | sed 's/refs\/heads\///g' | sed 's/refs\/tags\///g')}
39+
40+
echo "Target reference: $TARGET_REF"
41+
echo "ref=$TARGET_REF" >> $GITHUB_OUTPUT
42+
43+
build:
44+
name: Build
45+
needs: ref
46+
secrets: inherit
47+
uses: ./.github/workflows/_build.yaml
48+
with:
49+
env-name: prod-dr-us-west-2
50+
tag-name: ${{ needs.ref.outputs.target-ref }}
51+
git-ref: ${{ needs.ref.outputs.target-ref }}
52+
53+
migrations:
54+
name: Run Migrations in Prod-DR
55+
needs: [build, ref]
56+
secrets:
57+
slack-webhook: ${{ secrets.SLACK_WEBHOOK_DEPLOY_TO_DR }}
58+
uses: ./.github/workflows/_migrations.yaml
59+
with:
60+
env-name: prod-dr-us-west-2
61+
image-tag: ${{ needs.ref.outputs.target-ref }}
62+
63+
64+
deploy-prod:
65+
name: Deploy to Prod-DR
66+
needs: [ build, migrations, ref ]
67+
secrets:
68+
slack-webhook: ${{ secrets.SLACK_WEBHOOK_DEPLOY_TO_DR }}
69+
uses: ./.github/workflows/_deploy.yaml
70+
with:
71+
env-name: prod-dr-us-west-2
72+
image-tag: ${{ needs.ref.outputs.target-ref }}

.github/workflows/run_build_deploy_prod.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
with:
4949
tag-name: ${{ needs.ref.outputs.target-ref }}
5050
git-ref: ${{ needs.ref.outputs.target-ref }}
51+
env-name: prod
5152

5253
migrations:
5354
name: Run Migrations in Prod

.github/workflows/run_build_deploy_uat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
with:
4949
tag-name: ${{ needs.ref.outputs.target-ref }}
5050
git-ref: ${{ needs.ref.outputs.target-ref }}
51+
env-name: uat
5152

5253

5354
migrations:

src/apps/activity_assignments/service.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,15 @@ async def send_email_notification(
178178
else f"{domain}/{path}/{applet.id}"
179179
)
180180

181+
subject_text = service.get_localized_text_template(
182+
template_name="assignment_notification",
183+
language=language,
184+
applet_name=applet.display_name,
185+
)
186+
181187
message = MessageSchema(
182188
recipients=[respondent_subject.email],
183-
subject=self._get_email_assignment_subject(language),
189+
subject=subject_text,
184190
body=service.get_localized_html_template(
185191
template_name=self._get_email_template_name(),
186192
language=language,
@@ -482,11 +488,3 @@ async def get_assigned_activity_or_flow_ids_for_subject(
482488
@staticmethod
483489
def _get_email_template_name() -> str:
484490
return "new_activity_assignments"
485-
486-
@staticmethod
487-
def _get_email_assignment_subject(language: str) -> str:
488-
translations = {
489-
"en": "Assignment Notification",
490-
"fr": "Notification d'attribution",
491-
}
492-
return translations.get(language, translations["en"])

0 commit comments

Comments
 (0)