Skip to content

Commit 2ed0248

Browse files
committed
Update deployment workflows to disable record processor image build in continuous deployment. Adjusted output variable for image version in backend deployment workflow and refined implicit tag prefix reuse logic. Added AWS connection step in Lambda artifact deployment workflow, enhancing deployment efficiency and flexibility.
1 parent 6173d54 commit 2ed0248

4 files changed

Lines changed: 28 additions & 11 deletions

File tree

.github/workflows/continuous-deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: ./.github/workflows/deploy-backend.yml
2121
with:
2222
apigee_environment: internal-dev
23-
build_recordprocessor_image: true
23+
build_recordprocessor_image: false
2424
diff_base_sha: ${{ github.event.before }}
2525
diff_head_sha: ${{ github.sha }}
2626
run_diff_check: true

.github/workflows/deploy-backend.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ on:
3939
outputs:
4040
recordprocessor_image_version:
4141
description: Selected immutable image selector used for recordprocessor deployment
42-
value: ${{ jobs.deploy-recordprocessor-image.outputs.image_version }}
42+
value: ${{ jobs.deploy-recordprocessor-image.outputs.image_uri }}
4343
workflow_dispatch:
4444
inputs:
4545
apigee_environment:
@@ -120,7 +120,7 @@ jobs:
120120
dockerfile_path: lambdas/recordprocessor/Dockerfile
121121
ecr_repository: imms-recordprocessor-repo
122122
image_tag_prefix: ${{ inputs.sub_environment }}-
123-
allow_implicit_tag_prefix_reuse: ${{ startsWith(inputs.sub_environment, 'pr-') }}
123+
allow_implicit_tag_prefix_reuse: ${{ inputs.sub_environment == 'internal-dev' || startsWith(inputs.sub_environment, 'pr-') }}
124124

125125
terraform-plan:
126126
permissions:

.github/workflows/deploy-lambda-artifact.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ jobs:
122122
with:
123123
fetch-depth: 0
124124

125+
- name: Connect to AWS
126+
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
127+
with:
128+
aws-region: eu-west-2
129+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
130+
role-session-name: github-actions
131+
125132
- name: Select build or reuse path
126133
id: decide
127134
run: |
@@ -156,6 +163,23 @@ jobs:
156163
deployment_mode="build"
157164
elif ! git diff --quiet "${DIFF_BASE_SHA}" "${DIFF_HEAD_SHA}" -- "${paths[@]}"; then
158165
deployment_mode="build"
166+
elif [ -z "${IMAGE_VERSION}" ] && [ "${ALLOW_IMPLICIT_TAG_PREFIX_REUSE}" = "true" ]; then
167+
reusable_tag="$(
168+
aws ecr describe-images \
169+
--repository-name "${ECR_REPOSITORY}" \
170+
--region "${AWS_REGION}" \
171+
--filter tagStatus=TAGGED \
172+
--query 'reverse(sort_by(imageDetails,&imagePushedAt))[].imageTags[]' \
173+
--output text 2>/dev/null \
174+
| tr '\t' '\n' \
175+
| grep "^${TAG_PREFIX}" \
176+
| head -n1 || true
177+
)"
178+
179+
# If there is nothing reusable yet, bootstrap by building once.
180+
if [ -z "${reusable_tag}" ]; then
181+
deployment_mode="build"
182+
fi
159183
fi
160184
fi
161185
elif [ -z "${IMAGE_VERSION}" ]; then
@@ -164,13 +188,6 @@ jobs:
164188
165189
echo "deployment_mode=${deployment_mode}" >> "$GITHUB_OUTPUT"
166190
167-
- name: Connect to AWS
168-
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
169-
with:
170-
aws-region: eu-west-2
171-
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
172-
role-session-name: github-actions
173-
174191
- name: Login to Amazon ECR
175192
id: login-ecr
176193
if: ${{ steps.decide.outputs.deployment_mode == 'build' }}

lambdas/recordprocessor/src/batch_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def process_csv_to_fhir(incoming_message_body: dict) -> int:
3131
incoming_message_body["encoder"] = encoder
3232
interim_message_body = file_level_validation(incoming_message_body=incoming_message_body)
3333
except Exception as e: # pylint: disable=broad-exception-caught
34-
logger.error(f"File level validation failed: {e}") # If the file is invalid, processing should cease.
34+
logger.error(f"File level validation failed: {e}") # If the file is invalid, processing should cease
3535
return 0
3636

3737
file_id = interim_message_body.get("message_id")

0 commit comments

Comments
 (0)