From 475e3f00bbdc59b14e4152883d5ba92e87d92616 Mon Sep 17 00:00:00 2001 From: Chris Farris Date: Sat, 9 Dec 2023 07:21:37 -0500 Subject: [PATCH] Update sync-to-test.yaml --- .github/workflows/sync-to-test.yaml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-to-test.yaml b/.github/workflows/sync-to-test.yaml index c8b81c7..55273b5 100644 --- a/.github/workflows/sync-to-test.yaml +++ b/.github/workflows/sync-to-test.yaml @@ -1,5 +1,8 @@ name: Sync Test Branch to S3 +permissions: + contents: write + on: push: branches: @@ -17,7 +20,23 @@ jobs: --s3-prefix aws-account-automation-lambda-transform --output-template-file cloudformation/BillingMetrics-Template-Transformed.yaml \ --metadata build_ver=$(git rev-parse --short "$GITHUB_SHA") - aws s3 sync --delete cloudformation/ s3://${S3_BUCKET}/aws-account-automation/ + aws s3 sync --delete cloudformation/ s3://${S3_BUCKET}/aws-account-automation/ --content-type text/plain + + for object in `aws s3api list-objects-v2 --bucket ${S3_BUCKET} --prefix aws-account-automation/ --query Contents[].[Key] --output text` ; do + aws s3api list-object-versions --bucket ${S3_BUCKET} --prefix ${object} --query Versions[].[Key,VersionId,LastModified] --output text --max-items 3 + done | grep -v ^None$ > Latest-Test-Versions.txt + + aws s3api list-object-versions --bucket ${S3_BUCKET} --prefix aws-account-automation/ --query Versions[].[Key,VersionId,LastModified] --output text > Test-Versions.txt + + + git config user.name github-actions + git config user.email github-actions@github.com + git add Versions.txt Latest-Versions.txt + git commit -m "AutoGenerated Object Versions" + git push + + + env: S3_BUCKET: pht-cloudformation-dev AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}