From a62d22403bef4b07c368fb21127b9a055c79320c Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Fri, 1 Nov 2024 14:42:23 +0000 Subject: [PATCH 01/15] preproduction database restore --- .github/workflows/database-ptr.yml | 1 + .github/workflows/database-restore.yml | 1 + .github/workflows/database.yaml | 1 + global_config/preproduction.sh | 6 ++++++ 4 files changed, 9 insertions(+) create mode 100644 global_config/preproduction.sh diff --git a/.github/workflows/database-ptr.yml b/.github/workflows/database-ptr.yml index 8f7d68871..9c7122316 100644 --- a/.github/workflows/database-ptr.yml +++ b/.github/workflows/database-ptr.yml @@ -10,6 +10,7 @@ on: type: choice options: - test + - preproduction - production confirm-production: description: Must be set to true if restoring production diff --git a/.github/workflows/database-restore.yml b/.github/workflows/database-restore.yml index d6ab5352a..44d621113 100644 --- a/.github/workflows/database-restore.yml +++ b/.github/workflows/database-restore.yml @@ -11,6 +11,7 @@ on: options: - development - test + - preproduction - production confirm-production: description: Must be set to true if restoring production diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index 2d7a2c3e8..d8459a2cb 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -10,6 +10,7 @@ on: type: choice options: - test + - preproduction - production backup-file: description: | diff --git a/global_config/preproduction.sh b/global_config/preproduction.sh new file mode 100644 index 000000000..64adffb98 --- /dev/null +++ b/global_config/preproduction.sh @@ -0,0 +1,6 @@ +CONFIG=preproduction +ENVIRONMENT=preprod +CONFIG_SHORT=pp +AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test +AZURE_RESOURCE_PREFIX=s189t01 +KV_PURGE_PROTECTION=false From b4f94e03f4a2b60061fd6ef89170427becaadcf4 Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 10:03:00 +0000 Subject: [PATCH 02/15] preproduction database restore --- .github/workflows/database-ptr.yml | 4 ++-- .github/workflows/database-restore.yml | 6 +++--- global_config/preproduction.sh | 6 ------ 3 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 global_config/preproduction.sh diff --git a/.github/workflows/database-ptr.yml b/.github/workflows/database-ptr.yml index 9c7122316..223a37dda 100644 --- a/.github/workflows/database-ptr.yml +++ b/.github/workflows/database-ptr.yml @@ -10,7 +10,7 @@ on: type: choice options: - test - - preproduction + - preprod - production confirm-production: description: Must be set to true if restoring production @@ -46,7 +46,7 @@ jobs: - name: Set environment variables run: | source global_config/${{ inputs.environment }}.sh - tf_vars_file=${{ env.TF_VARS_PATH }}/${{ inputs.environment }}/variables.tfvars.json + tf_vars_file=${{ env.TF_VARS_PATH }}/${{ env.ENVIRONMENT }}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV diff --git a/.github/workflows/database-restore.yml b/.github/workflows/database-restore.yml index 44d621113..a12f5b4ff 100644 --- a/.github/workflows/database-restore.yml +++ b/.github/workflows/database-restore.yml @@ -11,7 +11,7 @@ on: options: - development - test - - preproduction + - preprod - production confirm-production: description: Must be set to true if restoring production @@ -46,7 +46,7 @@ jobs: - name: Set environment variables run: | source global_config/${{ inputs.environment }}.sh - tf_vars_file=${{ env.TF_VARS_PATH }}/${{ inputs.environment }}/variables.tfvars.json + tf_vars_file=${{ env.TF_VARS_PATH }}/${{ env.ENVIRONMENT }}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV @@ -65,7 +65,7 @@ jobs: with: storage-account: ${{ env.STORAGE_ACCOUNT_NAME }} resource-group: ${{ env.RESOURCE_GROUP_NAME }} - app-name: ${{ env.SERVICE_NAME }}-${{ inputs.environment }}-web + app-name: ${{ env.SERVICE_NAME }}-${{ env.ENVIRONMENT }}-web cluster: ${{ env.CLUSTER }} azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} backup-file: ${{ env.BACKUP_FILE }} diff --git a/global_config/preproduction.sh b/global_config/preproduction.sh deleted file mode 100644 index 64adffb98..000000000 --- a/global_config/preproduction.sh +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG=preproduction -ENVIRONMENT=preprod -CONFIG_SHORT=pp -AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test -AZURE_RESOURCE_PREFIX=s189t01 -KV_PURGE_PROTECTION=false From 2d7a88a8e1a421112d95ccb9d363830337bd6f2b Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 10:07:43 +0000 Subject: [PATCH 03/15] preproduction database restore --- .github/workflows/database.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index d8459a2cb..9a987c995 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -10,7 +10,7 @@ on: type: choice options: - test - - preproduction + - preprod - production backup-file: description: | @@ -62,7 +62,7 @@ jobs: - name: Set environment variables run: | source global_config/${DEPLOY_ENV}.sh - tf_vars_file=${TF_VARS_PATH}/${DEPLOY_ENV}/variables.tfvars.json + tf_vars_file=${TF_VARS_PATH}/${{ env.ENVIRONMENT }}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV @@ -92,7 +92,7 @@ jobs: with: storage-account: ${{ env.STORAGE_ACCOUNT_NAME }} resource-group: ${{ env.RESOURCE_GROUP_NAME }} - app-name: ${{ env.SERVICE_NAME }}-${{ env.DEPLOY_ENV }}-web + app-name: ${{ env.SERVICE_NAME }}-${{ env.ENVIRONMENT }}-web cluster: ${{ env.CLUSTER }} azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} backup-file: ${{ env.BACKUP_FILE }}.sql From df90f6b785674b4f88a8c662c1f03c313869fb92 Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 10:45:08 +0000 Subject: [PATCH 04/15] preproduction database restore --- .github/workflows/database.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index 9a987c995..da4d1f39e 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -55,9 +55,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - uses: azure/login@v2 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Set environment variables run: | @@ -78,6 +75,11 @@ jobs: echo "BACKUP_FILE=${BACKUP_FILE}" >> $GITHUB_ENV echo "KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-inf-kv" >> $GITHUB_ENV + - uses: azure/login@v2 + with: + environment: ${{ env.ENVIRONMENT }} + creds: ${{ secrets.AZURE_CREDENTIALS }} + - name: Fetch secrets from key vault uses: azure/CLI@v2 id: key-vault-secrets From f1622b0dce7a64ff9614cec3e5d4523d39d6a76b Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 12:36:37 +0000 Subject: [PATCH 05/15] preproduction database restore --- .github/workflows/database.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index da4d1f39e..dfa4aace4 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -55,7 +55,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set environment variables run: | source global_config/${DEPLOY_ENV}.sh @@ -75,7 +74,7 @@ jobs: echo "BACKUP_FILE=${BACKUP_FILE}" >> $GITHUB_ENV echo "KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-inf-kv" >> $GITHUB_ENV - - uses: azure/login@v2 + - uses: azure/login@v2 with: environment: ${{ env.ENVIRONMENT }} creds: ${{ secrets.AZURE_CREDENTIALS }} From fb88c0f926ebb49a020f91ee86c869af4fec25ff Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 12:43:54 +0000 Subject: [PATCH 06/15] preproduction database restore --- .github/workflows/database.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index dfa4aace4..ded1b2cfd 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -74,7 +74,8 @@ jobs: echo "BACKUP_FILE=${BACKUP_FILE}" >> $GITHUB_ENV echo "KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-inf-kv" >> $GITHUB_ENV - - uses: azure/login@v2 + - name: Azure login + uses: azure/login@v2 with: environment: ${{ env.ENVIRONMENT }} creds: ${{ secrets.AZURE_CREDENTIALS }} From 39827925876acecdb0274c44ba70a591eb2e7ccc Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 12:52:50 +0000 Subject: [PATCH 07/15] preproduction database restore --- .github/workflows/database.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index ded1b2cfd..151e80b95 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -76,8 +76,8 @@ jobs: - name: Azure login uses: azure/login@v2 + environment: ${{ env.ENVIRONMENT }} with: - environment: ${{ env.ENVIRONMENT }} creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Fetch secrets from key vault From c10f10908ec125a0e30ea0c428499e1481b55a82 Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 13:11:37 +0000 Subject: [PATCH 08/15] preproduction database restore --- .github/workflows/database.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index 151e80b95..9a987c995 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -55,6 +55,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + - name: Set environment variables run: | source global_config/${DEPLOY_ENV}.sh @@ -74,12 +78,6 @@ jobs: echo "BACKUP_FILE=${BACKUP_FILE}" >> $GITHUB_ENV echo "KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-inf-kv" >> $GITHUB_ENV - - name: Azure login - uses: azure/login@v2 - environment: ${{ env.ENVIRONMENT }} - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - name: Fetch secrets from key vault uses: azure/CLI@v2 id: key-vault-secrets From a513c6dff776801c1cbf21730bb1814fc08f1658 Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 13:36:46 +0000 Subject: [PATCH 09/15] preproduction database restore --- .github/workflows/database.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index 9a987c995..c0f0c0075 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -61,7 +61,7 @@ jobs: - name: Set environment variables run: | - source global_config/${DEPLOY_ENV}.sh + source global_config/${{ inputs.environment }}.sh tf_vars_file=${TF_VARS_PATH}/${{ env.ENVIRONMENT }}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV From 2ff01c001aa81b1f71927b3b5992a79475b76096 Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 14:00:24 +0000 Subject: [PATCH 10/15] preproduction database restore --- .github/workflows/database.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index c0f0c0075..d1c0058c3 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -61,8 +61,8 @@ jobs: - name: Set environment variables run: | - source global_config/${{ inputs.environment }}.sh - tf_vars_file=${TF_VARS_PATH}/${{ env.ENVIRONMENT }}/variables.tfvars.json + source global_config/${DEPLOY_ENV}.sh + tf_vars_file=${TF_VARS_PATH}/${CONFIG}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV From 390c170a50ce72772b1737859ff80e9c21c8785c Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 14:13:58 +0000 Subject: [PATCH 11/15] preproduction database restore --- .github/workflows/database.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/database.yaml b/.github/workflows/database.yaml index d1c0058c3..4d6c2df08 100644 --- a/.github/workflows/database.yaml +++ b/.github/workflows/database.yaml @@ -63,6 +63,7 @@ jobs: run: | source global_config/${DEPLOY_ENV}.sh tf_vars_file=${TF_VARS_PATH}/${CONFIG}/variables.tfvars.json + echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_ENV echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV From 4ea7492c5c3676fb0dea431fdd31333cb96c1e2f Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 14:30:52 +0000 Subject: [PATCH 12/15] preproduction database restore --- .github/workflows/database-ptr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/database-ptr.yml b/.github/workflows/database-ptr.yml index 223a37dda..f9de983c8 100644 --- a/.github/workflows/database-ptr.yml +++ b/.github/workflows/database-ptr.yml @@ -46,7 +46,7 @@ jobs: - name: Set environment variables run: | source global_config/${{ inputs.environment }}.sh - tf_vars_file=${{ env.TF_VARS_PATH }}/${{ env.ENVIRONMENT }}/variables.tfvars.json + tf_vars_file=${{ env.TF_VARS_PATH }}/${{ env.CONFIG }}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV From ca4b5ee01d8ed29c2704c880e61923bd97f6814e Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 14:36:47 +0000 Subject: [PATCH 13/15] preproduction database restore --- .github/workflows/database-ptr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/database-ptr.yml b/.github/workflows/database-ptr.yml index f9de983c8..e45a15f17 100644 --- a/.github/workflows/database-ptr.yml +++ b/.github/workflows/database-ptr.yml @@ -46,7 +46,7 @@ jobs: - name: Set environment variables run: | source global_config/${{ inputs.environment }}.sh - tf_vars_file=${{ env.TF_VARS_PATH }}/${{ env.CONFIG }}/variables.tfvars.json + tf_vars_file=${{ env.TF_VARS_PATH }}/${CONFIG}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV From fd526b7581e2cdbf846c85b0b18083d73936a28e Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 14:46:56 +0000 Subject: [PATCH 14/15] preproduction database restore --- .github/workflows/database-restore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/database-restore.yml b/.github/workflows/database-restore.yml index a12f5b4ff..77be99967 100644 --- a/.github/workflows/database-restore.yml +++ b/.github/workflows/database-restore.yml @@ -46,7 +46,7 @@ jobs: - name: Set environment variables run: | source global_config/${{ inputs.environment }}.sh - tf_vars_file=${{ env.TF_VARS_PATH }}/${{ env.ENVIRONMENT }}/variables.tfvars.json + tf_vars_file=${{ env.TF_VARS_PATH }}/${CONFIG}/variables.tfvars.json echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV @@ -65,7 +65,7 @@ jobs: with: storage-account: ${{ env.STORAGE_ACCOUNT_NAME }} resource-group: ${{ env.RESOURCE_GROUP_NAME }} - app-name: ${{ env.SERVICE_NAME }}-${{ env.ENVIRONMENT }}-web + app-name: ${{ env.SERVICE_NAME }}-${CONFIG}-web cluster: ${{ env.CLUSTER }} azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} backup-file: ${{ env.BACKUP_FILE }} From 282bb317670f8c32b6f5c1f70c8c80752b6ff33a Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 4 Nov 2024 14:54:49 +0000 Subject: [PATCH 15/15] preproduction database restore --- .github/workflows/database-restore.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/database-restore.yml b/.github/workflows/database-restore.yml index 77be99967..f1fb83a00 100644 --- a/.github/workflows/database-restore.yml +++ b/.github/workflows/database-restore.yml @@ -47,6 +47,7 @@ jobs: run: | source global_config/${{ inputs.environment }}.sh tf_vars_file=${{ env.TF_VARS_PATH }}/${CONFIG}/variables.tfvars.json + echo "CONFIG=${CONFIG}" >> $GITHUB_ENV echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV