From 8c06a6d86e216cd679f1810f7ca5bddd1b49264e Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 10:35:15 +0100 Subject: [PATCH 1/8] add new datetime and dry running --- .../workflows/delius-iaps-data-refresh.yml | 87 +++++++++++++++---- 1 file changed, 71 insertions(+), 16 deletions(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index 565bb3cba..6921d0adc 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -9,6 +9,10 @@ on: manually_specified_snapshot_id: # This is the name of the input description: 'Snapshot ID' required: false + dry_run: + description: 'Dry run only' + required: false + default: 'false' jobs: share-latest-manual-snapshot: @@ -39,44 +43,67 @@ jobs: echo "No snapshot found" exit 1 fi - echo SNAPSHOT_IDENTIFIER=${overnight_snapshot_identifier} >> $GITHUB_ENV - echo SNAPSHOT_IDENTIFIER=${overnight_snapshot_identifier} >> $GITHUB_OUTPUT + echo SOURCE_SNAPSHOT_IDENTIFIER=${overnight_snapshot_identifier} >> $GITHUB_ENV + echo SOURCE_SNAPSHOT_IDENTIFIER=${overnight_snapshot_identifier} >> $GITHUB_OUTPUT - name: Snapshot ID provided if: ${{ github.event.inputs.manually_specified_snapshot_id != '' }} run: | - echo SNAPSHOT_IDENTIFIER=${{ github.event.inputs.manually_specified_snapshot_id }} >> $GITHUB_ENV - echo SNAPSHOT_IDENTIFIER=${{ github.event.inputs.manually_specified_snapshot_id }} >> $GITHUB_OUTPUT + echo SOURCE_SNAPSHOT_IDENTIFIER=${{ github.event.inputs.manually_specified_snapshot_id }} >> $GITHUB_ENV + echo SOURCE_SNAPSHOT_IDENTIFIER=${{ github.event.inputs.manually_specified_snapshot_id }} >> $GITHUB_OUTPUT - name: Set snapshot name string run: | - echo DATETIME_STRING="$(date +%Y-%m-%d-%H-%M)" >> $GITHUB_ENV - echo SNAPSHOT_NAME="iaps-prod-snapshot-$(date +%Y-%m-%d-%H-%M)" >> $GITHUB_ENV + echo DATETIME_STRING="$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" + echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-$DATETIME_STRING" >> $GITHUB_ENV - name: Copy snapshot (prod-prod) + if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws rds copy-db-snapshot \ - --source-db-snapshot-identifier "${{ env.SNAPSHOT_IDENTIFIER }}" \ - --target-db-snapshot-identifier "${{ env.SNAPSHOT_NAME }}" \ + --source-db-snapshot-identifier "${{ env.SOURCE_SNAPSHOT_IDENTIFIER }}" \ + --target-db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ --region "eu-west-2" + - name: "[DRY RUN] Copy snapshot (prod-prod)" + if: ${{ github.event.inputs.dry_run == 'true' }} + run: | + echo "Dry run only, skipping snapshot copy" + echo "Command generated:" + echo "aws rds copy-db-snapshot \ + --source-db-snapshot-identifier '${{ env.SOURCE_SNAPSHOT_IDENTIFIER }}' \ + --target-db-snapshot-identifier '${{ env.SNAPSHOT_PROD_COPY_NAME }}' \ + --region 'eu-west-2'" - name: Wait for RDS Snapshot to be ready + if: ${{ github.event.inputs.dry_run == 'false' }} run: | for run in {1..5}; do aws rds wait db-snapshot-available \ - --db-snapshot-identifier "${{ env.SNAPSHOT_NAME }}" && break || sleep 10 * run + --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" && break || sleep 10 * run done - name: Share RDS snapshot with Pre-Prod + if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws rds modify-db-snapshot-attribute \ - --db-snapshot-identifier "${{ env.SNAPSHOT_NAME }}" \ + --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ --attribute-name restore \ --values-to-add "${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}" + + - name: "[DRY RUN] Share RDS snapshot with Pre-Prod" + if: ${{ github.event.inputs.dry_run == 'true' }} + run: | + echo "Dry run only, skipping share snapshot with pre-prod" + echo "Command generated:" + echo "aws rds modify-db-snapshot-attribute \ + --db-snapshot-identifier '${{ env.SNAPSHOT_PROD_COPY_NAME }}' \ + --attribute-name restore \ + --values-to-add '${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}'" - name: Configure AWS Credentials + if: ${{ github.event.inputs.dry_run == 'false' }} uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 with: role-to-assume: "arn:aws:iam::${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}:role/ci-data-refresher" @@ -85,37 +112,64 @@ jobs: - name: Set final snapshot name string run: | - echo FINAL_SNAPSHOT_NAME="iaps-refresh-ready-${{ env.DATETIME_STRING }}" >> $GITHUB_ENV + echo FINAL_SNAPSHOT_PROD_COPY_NAME="iaps-refresh-ready-${{ env.DATETIME_STRING }}" >> $GITHUB_ENV - name: Copy snapshot (prod[shared]-preprod) + if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws rds copy-db-snapshot \ - --source-db-snapshot-identifier "arn:aws:rds:eu-west-2:${{ secrets.IAPS_PRODUCTION_ACCOUNT_ID }}:snapshot:${{ env.SNAPSHOT_NAME }}" \ - --target-db-snapshot-identifier "${{ env.FINAL_SNAPSHOT_NAME }}" \ + --source-db-snapshot-identifier "arn:aws:rds:eu-west-2:${{ secrets.IAPS_PRODUCTION_ACCOUNT_ID }}:snapshot:${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ + --target-db-snapshot-identifier "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" \ --kms-key-id "arn:aws:kms:eu-west-2:374269020027:alias/rds-hmpps" \ --region "eu-west-2" + - name: "[DRY RUN] Copy snapshot (prod[shared]-preprod)" + if: ${{ github.event.inputs.dry_run == 'true' }} + run: | + echo "Dry run only, skipping copy snapshot (prod[shared]-preprod)" + echo "Command generated:" + echo "aws rds copy-db-snapshot \ + --source-db-snapshot-identifier 'arn:aws:rds:eu-west-2:${{ secrets.IAPS_PRODUCTION_ACCOUNT_ID }}:snapshot:${{ env.SNAPSHOT_PROD_COPY_NAME }}' \ + --target-db-snapshot-identifier '${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}' \ + --kms-key-id 'arn:aws:kms:eu-west-2:374269020027:alias/rds-hmpps' \ + --region 'eu-west-2'" + - name: Wait for RDS Snapshot to be ready in Pre-Prod + if: ${{ github.event.inputs.dry_run == 'false' }} run: | for run in {1..5}; do aws rds wait db-snapshot-available \ - --db-snapshot-identifier "${{ env.FINAL_SNAPSHOT_NAME }}" && break || sleep 10 * run + --db-snapshot-identifier "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" && break || sleep 10 * run done - name: Store identifier in SSM parameter store + if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws ssm put-parameter \ --name "/iaps/snapshot_id" \ - --value "${{ env.FINAL_SNAPSHOT_NAME }}" \ + --value "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" \ --type "String" \ --overwrite \ --region "eu-west-2" + - name: "[DRY RUN] Store identifier in SSM parameter store" + if: ${{ github.event.inputs.dry_run == 'true' }} + run: | + echo "Dry run only, skipping store identifier in SSM parameter store" + echo "Command generated:" + echo "aws ssm put-parameter \ + --name '/iaps/snapshot_id' \ + --value '${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}' \ + --type 'String' \ + --overwrite \ + --region 'eu-west-2'" + - name: Output snapshot identifier run: | - echo "Snapshot identifier: ${{env.FINAL_SNAPSHOT_NAME}}" + echo "Snapshot identifier: ${{env.FINAL_SNAPSHOT_PROD_COPY_NAME}}" - name: Generate token + if: github.event.inputs.dry_run == 'false' id: generate_token uses: tibdex/github-app-token@v1.8.0 with: @@ -123,6 +177,7 @@ jobs: private_key: ${{ secrets.HMPPS_BOT_PRIVATE_KEY }} - name: Trigger IAPS Workflow + if: github.event.inputs.dry_run == 'false' env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} run: gh workflow run delius-iaps --ref main -F action=deploy --repo ministryofjustice/modernisation-platform-environments From c9d0fffbbc1d10535afc62065c67abeb4d3e9961 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 10:36:43 +0100 Subject: [PATCH 2/8] add options helper --- .github/workflows/delius-iaps-data-refresh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index 6921d0adc..db75a0266 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -10,7 +10,7 @@ on: description: 'Snapshot ID' required: false dry_run: - description: 'Dry run only' + description: 'Dry run only [true|false]' required: false default: 'false' From aa928ca96783dc6decc7f450e918831a2a4fef11 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 11:01:41 +0100 Subject: [PATCH 3/8] change to use aws dry run --- .../workflows/delius-iaps-data-refresh.yml | 72 +++++-------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index db75a0266..bb782d195 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -23,6 +23,14 @@ jobs: sudo apt-get update sudo apt-get install -y python3-pip sudo pip3 install awscli + + - name: Dry run flag + run: | + if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then + echo DRY_RUN_FLAG="--dry-run" >> $GITHUB_ENV + else + echo DRY_RUN_FLAG="" >> $GITHUB_ENV + fi - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 @@ -38,7 +46,7 @@ jobs: --snapshot-type "automated" \ --db-instance-identifier "iaps" \ --query "reverse(sort_by(DBSnapshots, &SnapshotCreateTime))[0].DBSnapshotIdentifier" \ - --output text) + --output text ${{env.DRY_RUN_FLAG}}) if [ -z "$overnight_snapshot_identifier" ]; then echo "No snapshot found" exit 1 @@ -59,51 +67,28 @@ jobs: echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-$DATETIME_STRING" >> $GITHUB_ENV - name: Copy snapshot (prod-prod) - if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws rds copy-db-snapshot \ --source-db-snapshot-identifier "${{ env.SOURCE_SNAPSHOT_IDENTIFIER }}" \ --target-db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ - --region "eu-west-2" - - - name: "[DRY RUN] Copy snapshot (prod-prod)" - if: ${{ github.event.inputs.dry_run == 'true' }} - run: | - echo "Dry run only, skipping snapshot copy" - echo "Command generated:" - echo "aws rds copy-db-snapshot \ - --source-db-snapshot-identifier '${{ env.SOURCE_SNAPSHOT_IDENTIFIER }}' \ - --target-db-snapshot-identifier '${{ env.SNAPSHOT_PROD_COPY_NAME }}' \ - --region 'eu-west-2'" + --region "eu-west-2 ${{env.DRY_RUN_FLAG}}" - name: Wait for RDS Snapshot to be ready if: ${{ github.event.inputs.dry_run == 'false' }} run: | for run in {1..5}; do aws rds wait db-snapshot-available \ - --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" && break || sleep 10 * run + --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }} ${{env.DRY_RUN_FLAG}}" && break || sleep 10 * run done - name: Share RDS snapshot with Pre-Prod - if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws rds modify-db-snapshot-attribute \ --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ --attribute-name restore \ - --values-to-add "${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}" - - - name: "[DRY RUN] Share RDS snapshot with Pre-Prod" - if: ${{ github.event.inputs.dry_run == 'true' }} - run: | - echo "Dry run only, skipping share snapshot with pre-prod" - echo "Command generated:" - echo "aws rds modify-db-snapshot-attribute \ - --db-snapshot-identifier '${{ env.SNAPSHOT_PROD_COPY_NAME }}' \ - --attribute-name restore \ - --values-to-add '${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}'" + --values-to-add "${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }} ${{env.DRY_RUN_FLAG}}" - name: Configure AWS Credentials - if: ${{ github.event.inputs.dry_run == 'false' }} uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 with: role-to-assume: "arn:aws:iam::${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}:role/ci-data-refresher" @@ -115,24 +100,12 @@ jobs: echo FINAL_SNAPSHOT_PROD_COPY_NAME="iaps-refresh-ready-${{ env.DATETIME_STRING }}" >> $GITHUB_ENV - name: Copy snapshot (prod[shared]-preprod) - if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws rds copy-db-snapshot \ --source-db-snapshot-identifier "arn:aws:rds:eu-west-2:${{ secrets.IAPS_PRODUCTION_ACCOUNT_ID }}:snapshot:${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ --target-db-snapshot-identifier "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" \ --kms-key-id "arn:aws:kms:eu-west-2:374269020027:alias/rds-hmpps" \ - --region "eu-west-2" - - - name: "[DRY RUN] Copy snapshot (prod[shared]-preprod)" - if: ${{ github.event.inputs.dry_run == 'true' }} - run: | - echo "Dry run only, skipping copy snapshot (prod[shared]-preprod)" - echo "Command generated:" - echo "aws rds copy-db-snapshot \ - --source-db-snapshot-identifier 'arn:aws:rds:eu-west-2:${{ secrets.IAPS_PRODUCTION_ACCOUNT_ID }}:snapshot:${{ env.SNAPSHOT_PROD_COPY_NAME }}' \ - --target-db-snapshot-identifier '${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}' \ - --kms-key-id 'arn:aws:kms:eu-west-2:374269020027:alias/rds-hmpps' \ - --region 'eu-west-2'" + --region "eu-west-2" ${{env.DRY_RUN_FLAG}} - name: Wait for RDS Snapshot to be ready in Pre-Prod if: ${{ github.event.inputs.dry_run == 'false' }} @@ -143,33 +116,20 @@ jobs: done - name: Store identifier in SSM parameter store - if: ${{ github.event.inputs.dry_run == 'false' }} run: | aws ssm put-parameter \ --name "/iaps/snapshot_id" \ --value "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" \ --type "String" \ --overwrite \ - --region "eu-west-2" - - - name: "[DRY RUN] Store identifier in SSM parameter store" - if: ${{ github.event.inputs.dry_run == 'true' }} - run: | - echo "Dry run only, skipping store identifier in SSM parameter store" - echo "Command generated:" - echo "aws ssm put-parameter \ - --name '/iaps/snapshot_id' \ - --value '${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}' \ - --type 'String' \ - --overwrite \ - --region 'eu-west-2'" + --region "eu-west-2 ${{env.DRY_RUN_FLAG}}" - name: Output snapshot identifier run: | echo "Snapshot identifier: ${{env.FINAL_SNAPSHOT_PROD_COPY_NAME}}" - name: Generate token - if: github.event.inputs.dry_run == 'false' + if: ${{ github.event.inputs.dry_run == 'false' }} id: generate_token uses: tibdex/github-app-token@v1.8.0 with: @@ -177,7 +137,7 @@ jobs: private_key: ${{ secrets.HMPPS_BOT_PRIVATE_KEY }} - name: Trigger IAPS Workflow - if: github.event.inputs.dry_run == 'false' + if: ${{ github.event.inputs.dry_run == 'false' }} env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} run: gh workflow run delius-iaps --ref main -F action=deploy --repo ministryofjustice/modernisation-platform-environments From 2cc8603067ff5f7b6e2d788d4062bc785c793b7a Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 11:13:08 +0100 Subject: [PATCH 4/8] trigger workflow switch --- .../workflows/delius-iaps-data-refresh.yml | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index bb782d195..b9f92b74e 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -9,10 +9,9 @@ on: manually_specified_snapshot_id: # This is the name of the input description: 'Snapshot ID' required: false - dry_run: - description: 'Dry run only [true|false]' - required: false - default: 'false' + trigger_mp_workflow: + description: 'Trigger MP workflow for IAPS [true|false]' + default: 'true' jobs: share-latest-manual-snapshot: @@ -23,14 +22,6 @@ jobs: sudo apt-get update sudo apt-get install -y python3-pip sudo pip3 install awscli - - - name: Dry run flag - run: | - if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then - echo DRY_RUN_FLAG="--dry-run" >> $GITHUB_ENV - else - echo DRY_RUN_FLAG="" >> $GITHUB_ENV - fi - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 @@ -46,7 +37,7 @@ jobs: --snapshot-type "automated" \ --db-instance-identifier "iaps" \ --query "reverse(sort_by(DBSnapshots, &SnapshotCreateTime))[0].DBSnapshotIdentifier" \ - --output text ${{env.DRY_RUN_FLAG}}) + --output text) if [ -z "$overnight_snapshot_identifier" ]; then echo "No snapshot found" exit 1 @@ -71,14 +62,14 @@ jobs: aws rds copy-db-snapshot \ --source-db-snapshot-identifier "${{ env.SOURCE_SNAPSHOT_IDENTIFIER }}" \ --target-db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ - --region "eu-west-2 ${{env.DRY_RUN_FLAG}}" + --region "eu-west-2" - name: Wait for RDS Snapshot to be ready if: ${{ github.event.inputs.dry_run == 'false' }} run: | for run in {1..5}; do aws rds wait db-snapshot-available \ - --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }} ${{env.DRY_RUN_FLAG}}" && break || sleep 10 * run + --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" && break || sleep 10 * run done - name: Share RDS snapshot with Pre-Prod @@ -86,7 +77,7 @@ jobs: aws rds modify-db-snapshot-attribute \ --db-snapshot-identifier "${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ --attribute-name restore \ - --values-to-add "${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }} ${{env.DRY_RUN_FLAG}}" + --values-to-add "${{ secrets.IAPS_PREPRODUCTION_ACCOUNT_ID }}" - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 @@ -105,10 +96,9 @@ jobs: --source-db-snapshot-identifier "arn:aws:rds:eu-west-2:${{ secrets.IAPS_PRODUCTION_ACCOUNT_ID }}:snapshot:${{ env.SNAPSHOT_PROD_COPY_NAME }}" \ --target-db-snapshot-identifier "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" \ --kms-key-id "arn:aws:kms:eu-west-2:374269020027:alias/rds-hmpps" \ - --region "eu-west-2" ${{env.DRY_RUN_FLAG}} + --region "eu-west-2" - name: Wait for RDS Snapshot to be ready in Pre-Prod - if: ${{ github.event.inputs.dry_run == 'false' }} run: | for run in {1..5}; do aws rds wait db-snapshot-available \ @@ -122,14 +112,14 @@ jobs: --value "${{ env.FINAL_SNAPSHOT_PROD_COPY_NAME }}" \ --type "String" \ --overwrite \ - --region "eu-west-2 ${{env.DRY_RUN_FLAG}}" + --region "eu-west-2" - name: Output snapshot identifier run: | echo "Snapshot identifier: ${{env.FINAL_SNAPSHOT_PROD_COPY_NAME}}" - name: Generate token - if: ${{ github.event.inputs.dry_run == 'false' }} + if: ${{ github.event.inputs.trigger_mp_workflow == 'true' }} id: generate_token uses: tibdex/github-app-token@v1.8.0 with: @@ -137,7 +127,7 @@ jobs: private_key: ${{ secrets.HMPPS_BOT_PRIVATE_KEY }} - name: Trigger IAPS Workflow - if: ${{ github.event.inputs.dry_run == 'false' }} + if: ${{ github.event.inputs.trigger_mp_workflow == 'true' }} env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} run: gh workflow run delius-iaps --ref main -F action=deploy --repo ministryofjustice/modernisation-platform-environments From 7374ae81248d44c2adf7e28d8d16dc93946baa7c Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 11:20:00 +0100 Subject: [PATCH 5/8] fix string --- .github/workflows/delius-iaps-data-refresh.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index b9f92b74e..0889f9d15 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -54,8 +54,8 @@ jobs: - name: Set snapshot name string run: | - echo DATETIME_STRING="$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" - echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-$DATETIME_STRING" >> $GITHUB_ENV + echo DATETIME_STRING="$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" >> $GITHUB_ENV + echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-${{env.DATETIME_STRING}}" >> $GITHUB_ENV - name: Copy snapshot (prod-prod) run: | From e804a8c2d1b429f9afc1fe516cad16a10aae4ca8 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 11:22:41 +0100 Subject: [PATCH 6/8] sed again --- .github/workflows/delius-iaps-data-refresh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index 0889f9d15..44e76071f 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -55,7 +55,7 @@ jobs: - name: Set snapshot name string run: | echo DATETIME_STRING="$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" >> $GITHUB_ENV - echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-${{env.DATETIME_STRING}}" >> $GITHUB_ENV + echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" >> $GITHUB_ENV - name: Copy snapshot (prod-prod) run: | From d1066770db4d2c07530d3e1c9505089e066fad19 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 11:24:24 +0100 Subject: [PATCH 7/8] remove dry run --- .github/workflows/delius-iaps-data-refresh.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index 44e76071f..8603fcd9c 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -65,7 +65,6 @@ jobs: --region "eu-west-2" - name: Wait for RDS Snapshot to be ready - if: ${{ github.event.inputs.dry_run == 'false' }} run: | for run in {1..5}; do aws rds wait db-snapshot-available \ From 2d87c52f99943a5804b925b04b0f3a9ca5fd70f0 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Thu, 21 Sep 2023 11:35:35 +0100 Subject: [PATCH 8/8] add run id --- .github/workflows/delius-iaps-data-refresh.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/delius-iaps-data-refresh.yml b/.github/workflows/delius-iaps-data-refresh.yml index 8603fcd9c..a5eddb3a0 100644 --- a/.github/workflows/delius-iaps-data-refresh.yml +++ b/.github/workflows/delius-iaps-data-refresh.yml @@ -51,11 +51,10 @@ jobs: echo SOURCE_SNAPSHOT_IDENTIFIER=${{ github.event.inputs.manually_specified_snapshot_id }} >> $GITHUB_ENV echo SOURCE_SNAPSHOT_IDENTIFIER=${{ github.event.inputs.manually_specified_snapshot_id }} >> $GITHUB_OUTPUT - - name: Set snapshot name string run: | echo DATETIME_STRING="$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" >> $GITHUB_ENV - echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)" >> $GITHUB_ENV + echo SNAPSHOT_PROD_COPY_NAME="iaps-prod-snapshot-$(echo $SOURCE_SNAPSHOT_IDENTIFIER | sed s/"rds:iaps-"//)-${{ github.run_id }}" >> $GITHUB_ENV - name: Copy snapshot (prod-prod) run: | @@ -87,7 +86,7 @@ jobs: - name: Set final snapshot name string run: | - echo FINAL_SNAPSHOT_PROD_COPY_NAME="iaps-refresh-ready-${{ env.DATETIME_STRING }}" >> $GITHUB_ENV + echo FINAL_SNAPSHOT_PROD_COPY_NAME="iaps-refresh-ready-${{ env.DATETIME_STRING }}-${{ github.run_id }}" >> $GITHUB_ENV - name: Copy snapshot (prod[shared]-preprod) run: |