1010 - cron : ' 0 0 * * *'
1111 # Allows to run this workflow manually from the Actions tab for testing
1212 workflow_dispatch :
13+
14+
1315
1416jobs :
1517 auto-update :
@@ -21,11 +23,10 @@ jobs:
2123 NET_9_ARM64_Dockerfile : " LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile"
2224 NET_10_AMD64_Dockerfile : " LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile"
2325 NET_10_ARM64_Dockerfile : " LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile"
24- NET_11_AMD64_Dockerfile : " LambdaRuntimeDockerfiles/Images/net11/amd64/Dockerfile"
25- NET_11_ARM64_Dockerfile : " LambdaRuntimeDockerfiles/Images/net11/arm64/Dockerfile"
2626
2727 steps :
28- - uses : actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2
28+ # Checks-out the repository under $GITHUB_WORKSPACE
29+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2930 with :
3031 ref : ' dev'
3132
@@ -113,82 +114,39 @@ jobs:
113114 Write-Host "Skipping .NET 10 ARM64 update - No version detected"
114115 }
115116
116- # Update .NET 11 AMD64 Dockerfile
117- - name : Update .NET 11 AMD64
118- id : update-net11-amd64
119- shell : pwsh
120- env :
121- DOCKERFILE_PATH : ${{ env.NET_11_AMD64_Dockerfile }}
122- run : |
123- $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "11"
124- if (-not [string]::IsNullOrEmpty($version)) {
125- & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version
126- } else {
127- Write-Host "Skipping .NET 11 AMD64 update - No version detected"
128- }
129-
130- # Update .NET 11 ARM64 Dockerfile
131- - name : Update .NET 11 ARM64
132- id : update-net11-arm64
133- shell : pwsh
134- env :
135- DOCKERFILE_PATH : ${{ env.NET_11_ARM64_Dockerfile }}
136- run : |
137- $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "11"
138- if (-not [string]::IsNullOrEmpty($version)) {
139- & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version
140- } else {
141- Write-Host "Skipping .NET 11 ARM64 update - No version detected"
142- }
143-
144117 # Commit changes and create a branch
145118 - name : Commit and Push
146119 id : commit-push
147120 shell : pwsh
148121 run : |
149- git config --global user.email "github-aws-sdk-dotnet-automation@amazon.com"
150- git config --global user.name "aws-sdk-dotnet-automation"
151-
152- $remoteBranch = "chore/auto-update-Dockerfiles-daily"
153-
154- # Try to fetch the remote branch (it may not exist yet)
155- git fetch origin $remoteBranch 2>$null
156- $remoteExists = ($LASTEXITCODE -eq 0)
157-
158122 # Check if there are any changes to commit
159123 if (git status --porcelain) {
160-
124+ git config --global user.email "github-aws-sdk-dotnet-automation@amazon.com"
125+ git config --global user.name "aws-sdk-dotnet-automation"
126+
161127 # Generate timestamp for unique local branch name
162128 $timestamp = Get-Date -Format "yyyyMMddHHmmss"
163129 $localBranch = "chore/auto-update-Dockerfiles-daily-$timestamp"
164-
130+ $remoteBranch = "chore/auto-update-Dockerfiles-daily"
131+
165132 # Always create a new unique local branch
166133 git checkout -b $localBranch
167-
134+
168135 git add "**/*Dockerfile"
169136 git commit -m "chore: Daily ASP.NET Core version update in Dockerfiles"
170-
171- # If remote branch exists and there is no diff vs remote branch, skip pushing and PR creation
172- if ($remoteExists) {
173- git diff --quiet "origin/$remoteBranch...HEAD"
174- if ($LASTEXITCODE -eq 0) {
175- echo "No diff vs origin/$remoteBranch. Skipping push/PR creation."
176- Add-Content -Path $env:GITHUB_OUTPUT -Value "CHANGES_MADE=false"
177- exit 0
178- }
179- }
180-
181- # Only now delete + push (because we know it's different)
137+
138+ # Always delete the remote branch before pushing to avoid stale branch errors
182139 git push origin --delete $remoteBranch 2>$null
140+
141+ # Push local branch to remote branch (force push to consistent remote branch name)
183142 git push --force origin "${localBranch}:${remoteBranch}"
184-
143+
185144 # Write the remote branch name to GITHUB_OUTPUT for use in the PR step
186145 Add-Content -Path $env:GITHUB_OUTPUT -Value "BRANCH=$remoteBranch"
187146 Add-Content -Path $env:GITHUB_OUTPUT -Value "CHANGES_MADE=true"
188147 echo "Changes committed to local branch $localBranch and pushed to remote branch $remoteBranch"
189148 } else {
190149 echo "No changes detected in Dockerfiles, skipping PR creation"
191- Add-Content -Path $env:GITHUB_OUTPUT -Value "CHANGES_MADE=false"
192150 }
193151
194152 # Create a Pull Request
@@ -201,27 +159,25 @@ jobs:
201159 destination_branch : " dev"
202160 pr_title : ' chore: Daily ASP.NET Core version update in Dockerfiles'
203161 pr_body : " This PR automatically updates the Dockerfiles to use the latest ASP.NET Core version.
204-
162+
205163 Verify that the Dockerfiles have correct versions and matching SHA512 checksums for ASP.NET Core runtime.
206-
164+
207165 All .NET versions: https://dotnet.microsoft.com/en-us/download/dotnet
208-
166+
209167 *Description of changes:*
210168 \n ${{ format
211- (
212- '{0}\n {1}\n {2}\n {3}\n {4}\n {5}\n {6}\n {7}',
213- join(steps.update-net8-amd64.outputs.MESSAGE, '\n '),
214- join(steps.update-net8-arm64.outputs.MESSAGE, '\n '),
215- join(steps.update-net9-amd64.outputs.MESSAGE, '\n '),
216- join(steps.update-net9-arm64.outputs.MESSAGE, '\n '),
217- join(steps.update-net10-amd64.outputs.MESSAGE, '\n '),
218- join(steps.update-net10-arm64.outputs.MESSAGE, '\n '),
219- join(steps.update-net11-amd64.outputs.MESSAGE, '\n '),
220- join(steps.update-net11-arm64.outputs.MESSAGE, '\n ')
221- )
169+ (
170+ '{0}\n {1}\n {2}\n {3}\n {4}\n {5}',
171+ join(steps.update-net8-amd64.outputs.MESSAGE, '\n '),
172+ join(steps.update-net8-arm64.outputs.MESSAGE, '\n '),
173+ join(steps.update-net9-amd64.outputs.MESSAGE, '\n '),
174+ join(steps.update-net9-arm64.outputs.MESSAGE, '\n '),
175+ join(steps.update-net10-amd64.outputs.MESSAGE, '\n '),
176+ join(steps.update-net10-arm64.outputs.MESSAGE, '\n ')
177+ )
222178 }}"
223179 github_token : ${{ secrets.GITHUB_TOKEN }}
224-
180+
225181 # Add "Release Not Needed" label to the PR
226182 - name : Add Release Not Needed label
227183 if : ${{ steps.pull-request.outputs.pr_number }}
0 commit comments