From 7833333959d093aa6ac40fde46dbe79fd40d354b Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Wed, 26 Mar 2025 15:26:38 +0000 Subject: [PATCH 01/11] Enable continuous deployment for QA and Test --- .github/workflows/continuous-deployment.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index aea39e600b..aa98a2b5fa 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -1,5 +1,5 @@ name: Continuous deployment -run-name: Continuous deployment of ${{ github.ref }} to "copilotmigration" +run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: @@ -13,11 +13,19 @@ jobs: uses: ./.github/workflows/build-and-push-image.yml deploy-infrastructure: needs: test + strategy: + fail-fast: false + matrix: + environment: [qa, test] uses: ./.github/workflows/deploy-infrastructure.yml with: - environment: copilotmigration + environment: ${{ matrix.environment }} deploy-application: needs: [build-and-push-image, deploy-infrastructure] + strategy: + fail-fast: false + matrix: + environment: [ qa, test ] uses: ./.github/workflows/deploy-application.yml with: - environment: copilotmigration + environment: ${{ matrix.environment }} From aafc99db604635402dda57e79dab51898551547e Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Wed, 26 Mar 2025 15:28:11 +0000 Subject: [PATCH 02/11] Test workflow --- .github/workflows/continuous-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index aa98a2b5fa..687f385664 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -3,7 +3,7 @@ run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: - branches: [main] + branches: [MAV-921_continuous_deployment_job] jobs: test: From c46aeac8c784da5d05414027a5a2bacb2cc9302d Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Wed, 26 Mar 2025 16:06:13 +0000 Subject: [PATCH 03/11] Prevent name-clashes of multiple artifacts on single github runner * Make artifact names unique by appending environment name to it --- .github/workflows/deploy-application.yml | 8 ++++---- .github/workflows/deploy-infrastructure.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-application.yml b/.github/workflows/deploy-application.yml index bb20d88965..3dcd5a9396 100644 --- a/.github/workflows/deploy-application.yml +++ b/.github/workflows/deploy-application.yml @@ -77,7 +77,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: tfplan_app + name: tfplan_app-${{ inputs.environment }} path: ${{ runner.temp }}/tfplan apply-changes: @@ -98,7 +98,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: tfplan_app + name: tfplan_app-${{ inputs.environment }} path: ${{ runner.temp }} - name: Install terraform uses: hashicorp/setup-terraform@v3 @@ -116,7 +116,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: CODEDEPLOY_ENV + name: CODEDEPLOY_ENV-${{ inputs.environment }} path: ${{ runner.temp }}/CODEDEPLOY_ENV create-deployment: @@ -130,7 +130,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: CODEDEPLOY_ENV + name: CODEDEPLOY_ENV-${{ inputs.environment }} path: ${{ runner.temp }}/artifact - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/.github/workflows/deploy-infrastructure.yml b/.github/workflows/deploy-infrastructure.yml index b60584b220..0d58d73754 100644 --- a/.github/workflows/deploy-infrastructure.yml +++ b/.github/workflows/deploy-infrastructure.yml @@ -83,7 +83,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: tfplan_infrastructure + name: tfplan_infrastructure-${{ inputs.environment }} path: ${{ runner.temp }}/tfplan apply: @@ -104,7 +104,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: tfplan_infrastructure + name: tfplan_infrastructure-${{ inputs.environment }} path: ${{ runner.temp }} - name: Install terraform uses: hashicorp/setup-terraform@v3 From fb2e5d3b1e6be67a1b545c58c2686e2014392ba7 Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Wed, 26 Mar 2025 17:00:35 +0000 Subject: [PATCH 04/11] Enable manual deployment --- .github/workflows/continuous-deployment.yml | 29 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 687f385664..39c74c58ee 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -1,9 +1,26 @@ name: Continuous deployment -run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test +run-name: >- + ${{ github.event_name == 'workflow_dispatch' + && format('Deployment of ${{ github.ref_name }} to {0}', inputs.environment) + || 'Continuous deployment of ${{ github.ref_name }} to QA and Test' }} on: push: branches: [MAV-921_continuous_deployment_job] + workflow_dispatch: + inputs: + environment: + description: Deployment environment + required: true + type: choice + options: + - qa + - poc + - copilotmigration + - test + - preview + - training + - production jobs: test: @@ -16,7 +33,10 @@ jobs: strategy: fail-fast: false matrix: - environment: [qa, test] + environment: >- + ${{ fromJSON(github.event_name == 'workflow_dispatch' + && format('["{0}"]', inputs.environment) + || '["qa", "test"]') }} uses: ./.github/workflows/deploy-infrastructure.yml with: environment: ${{ matrix.environment }} @@ -25,7 +45,10 @@ jobs: strategy: fail-fast: false matrix: - environment: [ qa, test ] + environment: >- + ${{ fromJSON(github.event_name == 'workflow_dispatch' + && format('["{0}"]', inputs.environment) + || '["qa", "test"]') }} uses: ./.github/workflows/deploy-application.yml with: environment: ${{ matrix.environment }} From 83dbcaa0f7b907e537b68a6e41fd82d93aeaa13c Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Wed, 26 Mar 2025 17:20:08 +0000 Subject: [PATCH 05/11] Update run name --- .github/workflows/continuous-deployment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 39c74c58ee..13a4e1b639 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -1,8 +1,8 @@ name: Continuous deployment run-name: >- ${{ github.event_name == 'workflow_dispatch' - && format('Deployment of ${{ github.ref_name }} to {0}', inputs.environment) - || 'Continuous deployment of ${{ github.ref_name }} to QA and Test' }} + && format('Deployment of {0} to {1}', github.ref_name, inputs.environment) + || format('Continuous deployment of {0} to QA and Test', github.ref_name) }} on: push: From db10f0b680a420c960b8979648318ef6f4a599bd Mon Sep 17 00:00:00 2001 From: Brage Gording Date: Wed, 26 Mar 2025 20:56:02 +0000 Subject: [PATCH 06/11] MAV-921: Continuous deployment job - Ensure we only deploy application if infrastructure deploy is successful - This is not possible with fail-fast = false when using matrix - Refactor setup to use a template job, so we can ensure deploy application only triggers if deploy infrastructure of same job is successfull --- .github/workflows/continuous-deployment.yml | 36 ++++--------------- .github/workflows/deploy-application.yml | 3 ++ .github/workflows/deploy-mavis.yml | 39 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/deploy-mavis.yml diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 13a4e1b639..aba2bdb17d 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -1,8 +1,5 @@ name: Continuous deployment -run-name: >- - ${{ github.event_name == 'workflow_dispatch' - && format('Deployment of {0} to {1}', github.ref_name, inputs.environment) - || format('Continuous deployment of {0} to QA and Test', github.ref_name) }} +run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: @@ -10,45 +7,26 @@ on: workflow_dispatch: inputs: environment: - description: Deployment environment + description: "Deployment environment" required: true type: choice options: - qa - poc - - copilotmigration - test - preview - training - - production + - copilotmigration jobs: - test: - uses: ./.github/workflows/test.yml build-and-push-image: - needs: test uses: ./.github/workflows/build-and-push-image.yml - deploy-infrastructure: - needs: test - strategy: - fail-fast: false - matrix: - environment: >- - ${{ fromJSON(github.event_name == 'workflow_dispatch' - && format('["{0}"]', inputs.environment) - || '["qa", "test"]') }} - uses: ./.github/workflows/deploy-infrastructure.yml - with: - environment: ${{ matrix.environment }} - deploy-application: - needs: [build-and-push-image, deploy-infrastructure] + deploy-mavis: + needs: build-and-push-image strategy: fail-fast: false matrix: - environment: >- - ${{ fromJSON(github.event_name == 'workflow_dispatch' - && format('["{0}"]', inputs.environment) - || '["qa", "test"]') }} - uses: ./.github/workflows/deploy-application.yml + environment: ${{ fromJSON(github.event_name == 'workflow_dispatch' && format('["{0}"]', inputs.environment) || '["qa", "test"]') }} + uses: ./.github/workflows/deploy-mavis.yml with: environment: ${{ matrix.environment }} diff --git a/.github/workflows/deploy-application.yml b/.github/workflows/deploy-application.yml index 3dcd5a9396..e735fcea19 100644 --- a/.github/workflows/deploy-application.yml +++ b/.github/workflows/deploy-application.yml @@ -25,6 +25,9 @@ on: environment: required: true type: string + image_tag: + required: false + type: string env: aws-role: ${{ inputs.environment == 'production' diff --git a/.github/workflows/deploy-mavis.yml b/.github/workflows/deploy-mavis.yml new file mode 100644 index 0000000000..439bdeb805 --- /dev/null +++ b/.github/workflows/deploy-mavis.yml @@ -0,0 +1,39 @@ +name: Deploy Mavis on Environment +run-name: Deploying Mavis on ${{ inputs.environment }} + +on: + workflow_call: + inputs: + environment: + required: true + type: string + workflow_dispatch: + inputs: + environment: + description: Deployment environment + required: true + type: choice + options: + - qa + - poc + - test + - preview + - training + - production + - copilotmigration + image_tag: + description: Docker image tag + required: false + type: string + +jobs: + deploy-infrastructure: + uses: ./.github/workflows/deploy-infrastructure.yml + with: + environment: ${{ inputs.environment }} + deploy-application: + needs: deploy-infrastructure + uses: ./.github/workflows/deploy-application.yml + with: + environment: ${{ inputs.environment }} + image_tag: ${{ inputs.image_tag || github.sha }} From 9fca35d4a552a5fc3d186ea58b32e54d9a116ba6 Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Thu, 27 Mar 2025 14:09:00 +0000 Subject: [PATCH 07/11] Do not allow manual trigger of continuous deployment workflow * Manual deployments can already be done using the deploy-mavis workflow --- .github/workflows/continuous-deployment.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index aba2bdb17d..66883c43c8 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -4,29 +4,19 @@ run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: branches: [MAV-921_continuous_deployment_job] - workflow_dispatch: - inputs: - environment: - description: "Deployment environment" - required: true - type: choice - options: - - qa - - poc - - test - - preview - - training - - copilotmigration jobs: + test: + uses: ./.github/workflows/test.yml build-and-push-image: + needs: test uses: ./.github/workflows/build-and-push-image.yml deploy-mavis: needs: build-and-push-image strategy: fail-fast: false matrix: - environment: ${{ fromJSON(github.event_name == 'workflow_dispatch' && format('["{0}"]', inputs.environment) || '["qa", "test"]') }} + environment: ["qa", "test"] uses: ./.github/workflows/deploy-mavis.yml with: environment: ${{ matrix.environment }} From 75b8186f88ccaa670fd6723e235d35c54d937251 Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Thu, 27 Mar 2025 14:57:49 +0000 Subject: [PATCH 08/11] Require image tag as input * This makes it more explicit what's being deployed --- .github/workflows/deploy-mavis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-mavis.yml b/.github/workflows/deploy-mavis.yml index 439bdeb805..b4e0e7d07e 100644 --- a/.github/workflows/deploy-mavis.yml +++ b/.github/workflows/deploy-mavis.yml @@ -22,8 +22,8 @@ on: - production - copilotmigration image_tag: - description: Docker image tag - required: false + description: Docker image tag of the image to deploy + required: true type: string jobs: From 3fdef8405afe2211ca665b347f2d8f40475e58aa Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Thu, 27 Mar 2025 15:13:54 +0000 Subject: [PATCH 09/11] Revert branch name to main --- .github/workflows/continuous-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 66883c43c8..72f44f5d29 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -3,7 +3,7 @@ run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: - branches: [MAV-921_continuous_deployment_job] + branches: [main] jobs: test: From 10b94ba08039dc6ff2995e75e394dcee227f16e3 Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Thu, 27 Mar 2025 15:51:44 +0000 Subject: [PATCH 10/11] Circumvent IDE complaint * Pass image_tag in each case, also for the workflow_call trigger where it's not strictly necessary --- .github/workflows/continuous-deployment.yml | 3 ++- .github/workflows/deploy-mavis.yml | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 72f44f5d29..e2ca2543b5 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -3,7 +3,7 @@ run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: - branches: [main] + branches: [MAV-921_continuous_deployment_job] jobs: test: @@ -20,3 +20,4 @@ jobs: uses: ./.github/workflows/deploy-mavis.yml with: environment: ${{ matrix.environment }} + image_tag: ${{ github.sha }} diff --git a/.github/workflows/deploy-mavis.yml b/.github/workflows/deploy-mavis.yml index b4e0e7d07e..73341e8c3b 100644 --- a/.github/workflows/deploy-mavis.yml +++ b/.github/workflows/deploy-mavis.yml @@ -7,6 +7,10 @@ on: environment: required: true type: string + image_tag: + description: Docker image tag of the image to deploy + required: true + type: string workflow_dispatch: inputs: environment: @@ -36,4 +40,4 @@ jobs: uses: ./.github/workflows/deploy-application.yml with: environment: ${{ inputs.environment }} - image_tag: ${{ inputs.image_tag || github.sha }} + image_tag: ${{ inputs.image_tag }} From 98c295b18c09bd6a308b6bcb6e5fc0071f5c80d9 Mon Sep 17 00:00:00 2001 From: Moritz Bogs Date: Thu, 27 Mar 2025 16:07:49 +0000 Subject: [PATCH 11/11] Revert branch name to main --- .github/workflows/continuous-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index e2ca2543b5..dc58703885 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -3,7 +3,7 @@ run-name: Continuous deployment of ${{ github.ref_name }} to QA and Test on: push: - branches: [MAV-921_continuous_deployment_job] + branches: [main] jobs: test: