Skip to content

Commit 0ae6338

Browse files
Automatically update bootstrap template (#897)
* automatically update bootstrap generate change file use v8 use release workflow secret remove whitespace from bottom use version to detect changes fix warning point to specific tag use cli for creating PR pin more versions * Add comments * use new workflow * Update AutoUpdateBootstrap.yml
1 parent a9ad18c commit 0ae6338

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-2
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Auto Update Bootstrap Version Changes
2+
3+
on:
4+
schedule:
5+
# Runs at 00:00 UTC every Monday
6+
- cron: '0 0 * * 1'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
id-token: write
13+
14+
jobs:
15+
detect-cdk-bootstrap-changes:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Configure AWS Credentials
19+
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 #v4.1.0
20+
with:
21+
role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }}
22+
aws-region: us-west-2
23+
24+
- name: Retrieve secret from AWS Secrets Manager
25+
uses: aws-actions/aws-secretsmanager-get-secrets@fbd65ea98e018858715f591f03b251f02b2316cb #v2.0.8
26+
with:
27+
secret-ids: |
28+
AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }}
29+
parse-json-secrets: true
30+
31+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
32+
with:
33+
fetch-depth: '0'
34+
ref: dev
35+
token: ${{ env.AWS_SECRET_TOKEN }}
36+
37+
- name: Setup .NET
38+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 #v4.3.1
39+
with:
40+
dotnet-version: '8.0.x'
41+
42+
- name: Install AWS CDK
43+
run: |
44+
npm install -g aws-cdk
45+
46+
- name: Create temporary directory
47+
run: mkdir -p temp_cdk
48+
49+
- name: Save New CDK Bootstrap Template
50+
working-directory: temp_cdk
51+
run: |
52+
cdk acknowledge 32775
53+
cdk bootstrap --show-template > newTemplate.yml
54+
55+
- name: Update Template with Required Policies
56+
working-directory: temp_cdk
57+
run: |
58+
yq eval '.Resources.StagingBucket.UpdateReplacePolicy = "Delete"' -i newTemplate.yml
59+
yq eval '.Resources.StagingBucket.DeletionPolicy = "Delete"' -i newTemplate.yml
60+
61+
- name: Check for version changes
62+
id: check_version
63+
run: |
64+
OLD_VERSION=$(yq eval '.Resources.CdkBootstrapVersion.Properties.Value' src/AWS.Deploy.Orchestration/CDK/CDKBootstrapTemplate.yaml)
65+
NEW_VERSION=$(yq eval '.Resources.CdkBootstrapVersion.Properties.Value' temp_cdk/newTemplate.yml)
66+
67+
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
68+
echo "Version changed from $OLD_VERSION to $NEW_VERSION"
69+
echo "version_changed=true" >> $GITHUB_OUTPUT
70+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
71+
else
72+
echo "No version change detected"
73+
echo "version_changed=false" >> $GITHUB_OUTPUT
74+
fi
75+
76+
- name: Update CDK Bootstrap Template
77+
if: steps.check_version.outputs.version_changed == 'true'
78+
run: |
79+
cp temp_cdk/newTemplate.yml src/AWS.Deploy.Orchestration/CDK/CDKBootstrapTemplate.yaml
80+
81+
- name: Generate change file
82+
if: steps.check_version.outputs.version_changed == 'true'
83+
env:
84+
NEW_VERSION: ${{ steps.check_version.outputs.new_version }}
85+
run: |
86+
dotnet tool install -g autover --version 0.0.25
87+
autover change --project-name "AWS.Deploy.CLI" -m "Update CDK Bootstrap template to version $NEW_VERSION"
88+
89+
- name: Setup Git User
90+
run: |
91+
git config --global user.email "[email protected]"
92+
git config --global user.name "aws-sdk-dotnet-automation"
93+
94+
- name: Create Pull Request
95+
if: steps.check_version.outputs.version_changed == 'true'
96+
env:
97+
GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }}
98+
run: |
99+
git checkout -b update-cdk-bootstrap-template
100+
git add src/AWS.Deploy.Orchestration/CDK/CDKBootstrapTemplate.yaml .autover/
101+
git commit -m "chore: update CDK bootstrap template to version ${{ steps.check_version.outputs.new_version }}"
102+
git push origin update-cdk-bootstrap-template
103+
gh pr create \
104+
--title "Update CDK Bootstrap Template to Version ${{ steps.check_version.outputs.new_version }}" \
105+
--base dev \
106+
--head update-cdk-bootstrap-template \
107+
--delete-branch

src/AWS.Deploy.Orchestration/CDK/CDKBootstrapTemplate.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,5 +658,4 @@ Outputs:
658658
Value:
659659
Fn::GetAtt:
660660
- CdkBootstrapVersion
661-
- Value
662-
661+
- Value

0 commit comments

Comments
 (0)