|
| 1 | +name: Auto-Update Lambda Dockerfiles Daily |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + pull-requests: write |
| 6 | + |
| 7 | +on: |
| 8 | + # Run daily at midnight UTC |
| 9 | + schedule: |
| 10 | + - cron: '0 0 * * *' |
| 11 | + # Allows to run this workflow manually from the Actions tab for testing |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +jobs: |
| 17 | + auto-update: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + env: |
| 20 | + NET_8_AMD64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net8/amd64/Dockerfile" |
| 21 | + NET_8_ARM64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net8/arm64/Dockerfile" |
| 22 | + NET_9_AMD64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net9/amd64/Dockerfile" |
| 23 | + NET_9_ARM64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile" |
| 24 | + NET_10_AMD64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile" |
| 25 | + NET_10_ARM64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile" |
| 26 | + |
| 27 | + steps: |
| 28 | + # Checks-out the repository under $GITHUB_WORKSPACE |
| 29 | + - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 #v4.2.2 |
| 30 | + with: |
| 31 | + ref: 'dev' |
| 32 | + |
| 33 | + # Update .NET 8 AMD64 Dockerfile |
| 34 | + - name: Update .NET 8 AMD64 |
| 35 | + id: update-net8-amd64 |
| 36 | + shell: pwsh |
| 37 | + env: |
| 38 | + DOCKERFILE_PATH: ${{ env.NET_8_AMD64_Dockerfile }} |
| 39 | + run: | |
| 40 | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "8" |
| 41 | + if (-not [string]::IsNullOrEmpty($version)) { |
| 42 | + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version |
| 43 | + } else { |
| 44 | + Write-Host "Skipping .NET 8 AMD64 update - No version detected" |
| 45 | + } |
| 46 | +
|
| 47 | + # Update .NET 8 ARM64 Dockerfile |
| 48 | + - name: Update .NET 8 ARM64 |
| 49 | + id: update-net8-arm64 |
| 50 | + shell: pwsh |
| 51 | + env: |
| 52 | + DOCKERFILE_PATH: ${{ env.NET_8_ARM64_Dockerfile }} |
| 53 | + run: | |
| 54 | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "8" |
| 55 | + if (-not [string]::IsNullOrEmpty($version)) { |
| 56 | + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version |
| 57 | + } else { |
| 58 | + Write-Host "Skipping .NET 8 ARM64 update - No version detected" |
| 59 | + } |
| 60 | +
|
| 61 | + # Update .NET 9 AMD64 Dockerfile |
| 62 | + - name: Update .NET 9 AMD64 |
| 63 | + id: update-net9-amd64 |
| 64 | + shell: pwsh |
| 65 | + env: |
| 66 | + DOCKERFILE_PATH: ${{ env.NET_9_AMD64_Dockerfile }} |
| 67 | + run: | |
| 68 | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "9" |
| 69 | + if (-not [string]::IsNullOrEmpty($version)) { |
| 70 | + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version |
| 71 | + } else { |
| 72 | + Write-Host "Skipping .NET 9 AMD64 update - No version detected" |
| 73 | + } |
| 74 | +
|
| 75 | + # Update .NET 9 ARM64 Dockerfile |
| 76 | + - name: Update .NET 9 ARM64 |
| 77 | + id: update-net9-arm64 |
| 78 | + shell: pwsh |
| 79 | + env: |
| 80 | + DOCKERFILE_PATH: ${{ env.NET_9_ARM64_Dockerfile }} |
| 81 | + run: | |
| 82 | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "9" |
| 83 | + if (-not [string]::IsNullOrEmpty($version)) { |
| 84 | + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version |
| 85 | + } else { |
| 86 | + Write-Host "Skipping .NET 9 ARM64 update - No version detected" |
| 87 | + } |
| 88 | +
|
| 89 | + # Update .NET 10 AMD64 Dockerfile |
| 90 | + - name: Update .NET 10 AMD64 |
| 91 | + id: update-net10-amd64 |
| 92 | + shell: pwsh |
| 93 | + env: |
| 94 | + DOCKERFILE_PATH: ${{ env.NET_10_AMD64_Dockerfile }} |
| 95 | + run: | |
| 96 | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "10" |
| 97 | + if (-not [string]::IsNullOrEmpty($version)) { |
| 98 | + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version |
| 99 | + } else { |
| 100 | + Write-Host "Skipping .NET 10 AMD64 update - No version detected" |
| 101 | + } |
| 102 | +
|
| 103 | + # Update .NET 10 ARM64 Dockerfile |
| 104 | + - name: Update .NET 10 ARM64 |
| 105 | + id: update-net10-arm64 |
| 106 | + shell: pwsh |
| 107 | + env: |
| 108 | + DOCKERFILE_PATH: ${{ env.NET_10_ARM64_Dockerfile }} |
| 109 | + run: | |
| 110 | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "10" |
| 111 | + if (-not [string]::IsNullOrEmpty($version)) { |
| 112 | + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $version |
| 113 | + } else { |
| 114 | + Write-Host "Skipping .NET 10 ARM64 update - No version detected" |
| 115 | + } |
| 116 | +
|
| 117 | + # Commit changes and create a branch |
| 118 | + - name: Commit and Push |
| 119 | + id: commit-push |
| 120 | + shell: pwsh |
| 121 | + run: | |
| 122 | + # Check if there are any changes to commit |
| 123 | + if (git status --porcelain) { |
| 124 | + git config --global user.email "[email protected]" |
| 125 | + git config --global user.name "aws-sdk-dotnet-automation" |
| 126 | + |
| 127 | + # Generate timestamp for unique local branch name |
| 128 | + $timestamp = Get-Date -Format "yyyyMMddHHmmss" |
| 129 | + $localBranch = "chore/auto-update-Dockerfiles-daily-$timestamp" |
| 130 | + $remoteBranch = "chore/auto-update-Dockerfiles-daily" |
| 131 | + |
| 132 | + # Always create a new unique local branch |
| 133 | + git checkout -b $localBranch |
| 134 | + |
| 135 | + git add "**/*Dockerfile" |
| 136 | + git commit -m "chore: Daily ASP.NET Core version update in Dockerfiles" |
| 137 | + |
| 138 | + # Push local branch to remote branch (force push to consistent remote branch name) |
| 139 | + git push --force-with-lease origin "${localBranch}:${remoteBranch}" |
| 140 | + |
| 141 | + # Write the remote branch name to GITHUB_OUTPUT for use in the PR step |
| 142 | + Add-Content -Path $env:GITHUB_OUTPUT -Value "BRANCH=$remoteBranch" |
| 143 | + Add-Content -Path $env:GITHUB_OUTPUT -Value "CHANGES_MADE=true" |
| 144 | + echo "Changes committed to local branch $localBranch and pushed to remote branch $remoteBranch" |
| 145 | + } else { |
| 146 | + echo "No changes detected in Dockerfiles, skipping PR creation" |
| 147 | + } |
| 148 | +
|
| 149 | + # Create a Pull Request |
| 150 | + - name: Create Pull Request |
| 151 | + id: pull-request |
| 152 | + if: ${{ steps.commit-push.outputs.CHANGES_MADE == 'true' }} |
| 153 | + uses: repo-sync/pull-request@v2 |
| 154 | + with: |
| 155 | + source_branch: ${{ steps.commit-push.outputs.BRANCH }} |
| 156 | + destination_branch: "dev" |
| 157 | + pr_title: 'chore: Daily ASP.NET Core version update in Dockerfiles' |
| 158 | + pr_body: "This PR automatically updates the Dockerfiles to use the latest ASP.NET Core version. |
| 159 | + |
| 160 | + Verify that the Dockerfiles have correct versions and matching SHA512 checksums for ASP.NET Core runtime. |
| 161 | + |
| 162 | + All .NET versions: https://dotnet.microsoft.com/en-us/download/dotnet |
| 163 | + |
| 164 | + *Description of changes:* |
| 165 | + \n${{ format |
| 166 | + ( |
| 167 | + '{0}\n{1}\n{2}\n{3}\n{4}\n{5}', |
| 168 | + join(steps.update-net8-amd64.outputs.MESSAGE, '\n'), |
| 169 | + join(steps.update-net8-arm64.outputs.MESSAGE, '\n'), |
| 170 | + join(steps.update-net9-amd64.outputs.MESSAGE, '\n'), |
| 171 | + join(steps.update-net9-arm64.outputs.MESSAGE, '\n'), |
| 172 | + join(steps.update-net10-amd64.outputs.MESSAGE, '\n'), |
| 173 | + join(steps.update-net10-arm64.outputs.MESSAGE, '\n') |
| 174 | + ) |
| 175 | + }}" |
| 176 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 177 | + |
| 178 | + # Add "Release Not Needed" label to the PR |
| 179 | + - name: Add Release Not Needed label |
| 180 | + if: ${{ steps.pull-request.outputs.pr_number }} |
| 181 | + uses: actions/github-script@v6 |
| 182 | + with: |
| 183 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 184 | + script: | |
| 185 | + github.rest.issues.addLabels({ |
| 186 | + owner: context.repo.owner, |
| 187 | + repo: context.repo.repo, |
| 188 | + issue_number: ${{ steps.pull-request.outputs.pr_number }}, |
| 189 | + labels: ['Release Not Needed'] |
| 190 | + }) |
0 commit comments