Skip to content

Commit e77df1b

Browse files
Update: [AEA-5929] - Copy KB Docs from INT to PROD (#315)
## Summary - Purge documents in prod before syncing --- <img width="628" height="1050" alt="image" src="https://github.com/user-attachments/assets/d4f00b79-229c-4f92-8268-04fac16fe598" /> --------- Co-authored-by: bencegadanyi1-nhs <bence.gadanyi1@nhs.net>
1 parent fabe280 commit e77df1b

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/actions/sync_documents/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
TARGET_CLOUD_FORMATION_DEPLOY_ROLE:
1515
required: true
1616
description: "The role to assume for the target account"
17+
PURGE_ENVIRONMENT:
18+
required: false
19+
description: "Whether to remove all existing files in the target environment before syncing (true/false)"
20+
default: "false"
1721

1822
runs:
1923
using: "composite"
@@ -76,6 +80,18 @@ runs:
7680
fi
7781
printf "\n"
7882
83+
- name: Clear Target Environment
84+
shell: bash
85+
run: |
86+
if [ "$PURGE_ENVIRONMENT" == "true" ]; then
87+
echo "Purging s3://${{ steps.find-destination-bucket.outputs.BUCKET_NAME }}..."
88+
aws s3 rm s3://${{ steps.find-destination-bucket.outputs.BUCKET_NAME }} --recursive
89+
else
90+
echo "Purge disabled. Skipping deletion of files in target bucket."
91+
exit 0
92+
fi
93+
printf "\n"
94+
7995
- name: Upload Files to Target S3
8096
shell: bash
8197
run: |

.github/workflows/release_all_stacks.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,15 @@ jobs:
199199
env:
200200
TARGET_ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT }}
201201

202-
- name: Sync Documents - INT to lower environments
202+
- name: Sync Documents
203203
uses: ./.github/actions/sync_documents
204-
if: ${{ (inputs.TARGET_ENVIRONMENT == 'dev' || inputs.TARGET_ENVIRONMENT == 'qa' || inputs.TARGET_ENVIRONMENT == 'dev-pr') && (inputs.DEPLOY_CODE == true || inputs.IS_PULL_REQUEST == true) }}
204+
if: ${{ (inputs.TARGET_ENVIRONMENT != 'int') && (inputs.DEPLOY_CODE == true || inputs.IS_PULL_REQUEST == true) }}
205205
with:
206206
TARGET_ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT }}
207207
STACK: ${{ inputs.STACK_NAME }}
208208
INT_ASSIST_ME_DOCUMENT_SYNC_ROLE: ${{ secrets.INT_ASSIST_ME_DOCUMENT_SYNC_ROLE }}
209209
TARGET_CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }}
210+
PURGE_ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT == 'prod' }}
210211

211212
- name: create_int_release_notes
212213
uses: ./.github/actions/update_confluence_jira

packages/cdk/constructs/S3Bucket.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export class S3Bucket extends Construct {
6666
"s3:PutObjectLegalHold",
6767
"s3:PutObjectRetention",
6868
"s3:PutObjectTagging",
69-
"s3:PutObjectVersionTagging"
69+
"s3:PutObjectVersionTagging",
70+
"s3:DeleteObject",
71+
"s3:DeleteObjectVersion"
7072
],
7173
resources: [
7274
bucket.bucketArn,

0 commit comments

Comments
 (0)