Revisiting AWS Config Recorder Management #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync Master Branch to S3 | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
sync-files: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run Sync | |
run: | | |
aws cloudformation package --template-file cloudformation/BillingMetrics-Template.yaml --s3-bucket ${S3_BUCKET} \ | |
--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/ | |
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-Versions.txt | |
aws s3api list-object-versions --bucket pht-cloudformation --prefix aws-account-automation/ --query Versions[].[Key,VersionId,LastModified] --output text > Versions.txt | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add Versions.txt Latest-Versions.txt | |
git commit -m "AutoGenerated Object Versions" | |
git push | |
env: | |
S3_BUCKET: pht-cloudformation | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'us-east-1' | |
#EOF |