Skip to content

Commit dc8d021

Browse files
committed
Enhance deployment workflows with recordprocessor change detection
- Added a new job to detect changes in the recordprocessor directory, influencing the build process for the Docker image. - Updated the deployment workflows to conditionally build the recordprocessor image based on detected changes. - Improved tagging of Docker images to include a 'latest' tag alongside the versioned tag for better image management. - Adjusted dependencies in the deployment jobs to ensure proper sequencing and execution based on change detection.
1 parent 05c2220 commit dc8d021

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/continuous-deployment.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,31 @@ jobs:
1515
secrets:
1616
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1717

18+
detect-recordprocessor-changes:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
has_changes: ${{ steps.detect.outputs.has_changes }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Detect recordprocessor changes compared to master
29+
id: detect
30+
run: |
31+
if git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -q '^lambdas/recordprocessor/'; then
32+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
35+
fi
36+
1837
deploy-internal-dev-backend:
19-
needs: [run-quality-checks]
38+
needs: [run-quality-checks, detect-recordprocessor-changes]
2039
uses: ./.github/workflows/deploy-backend.yml
2140
with:
2241
apigee_environment: internal-dev
23-
build_recordprocessor_image: true
42+
build_recordprocessor_image: ${{needs.detect-recordprocessor-changes.outputs.has_changes == 'true'}}
2443
create_mns_subscription: true
2544
environment: dev
2645
sub_environment: internal-dev
@@ -76,14 +95,14 @@ jobs:
7695
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}
7796

7897
deploy-higher-dev-envs:
79-
needs: [run-internal-dev-tests]
98+
needs: [run-internal-dev-tests, detect-recordprocessor-changes]
8099
strategy:
81100
matrix:
82101
sub_environment_name: [ref, internal-qa]
83102
uses: ./.github/workflows/deploy-backend.yml
84103
with:
85104
apigee_environment: ${{ matrix.sub_environment_name }}
86-
build_recordprocessor_image: true
105+
build_recordprocessor_image: ${{needs.detect-recordprocessor-changes.outputs.has_changes == 'true'}}
87106
create_mns_subscription: true
88107
environment: dev
89108
sub_environment: ${{ matrix.sub_environment_name }}

.github/workflows/deploy-backend.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ jobs:
100100
IMAGE_TAG="${SUB_ENVIRONMENT}-${GITHUB_SHA}"
101101
REPOSITORY_NAME="imms-recordprocessor-repo"
102102
IMAGE_URI="${ECR_REGISTRY}/${REPOSITORY_NAME}:${IMAGE_TAG}"
103+
LATEST_IMAGE_URI="${ECR_REGISTRY}/${REPOSITORY_NAME}:latest"
103104
104105
docker build -f recordprocessor/Dockerfile -t "${IMAGE_URI}" .
105106
docker push "${IMAGE_URI}"
107+
docker tag "${IMAGE_URI}" "${LATEST_IMAGE_URI}"
108+
docker push "${LATEST_IMAGE_URI}"
106109
107110
- name: Skip image build
108111
if: ${{ !inputs.build_recordprocessor_image }}

.github/workflows/pr-deploy-and-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ concurrency:
1111
jobs:
1212
detect-recordprocessor-changes:
1313
runs-on: ubuntu-latest
14+
if: github.event.action == 'synchronize'
1415
outputs:
1516
has_changes: ${{ steps.detect.outputs.has_changes }}
1617
steps:
@@ -37,10 +38,11 @@ jobs:
3738

3839
deploy-pr-backend:
3940
needs: [run-quality-checks, detect-recordprocessor-changes]
41+
if: ${{ always() && !failure() && !cancelled() }}
4042
uses: ./.github/workflows/deploy-backend.yml
4143
with:
4244
apigee_environment: internal-dev
43-
build_recordprocessor_image: ${{ github.event.action == 'opened' || needs.detect-recordprocessor-changes.outputs.has_changes == 'true' }}
45+
build_recordprocessor_image: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || needs.detect-recordprocessor-changes.outputs.has_changes == 'true' }}
4446
create_mns_subscription: true
4547
environment: dev
4648
sub_environment: pr-${{github.event.pull_request.number}}

0 commit comments

Comments
 (0)