1212 paths :
1313 - ' src/AspNetCore/**/*'
1414 - ' .github/workflows/main_build-aspnetcore.yml'
15+
16+ # For jwt auth to Akeyless and ability to publish docker images to local repository
17+ permissions :
18+ contents : read
19+ packages : write
20+
1521env :
1622 CONTAINER_BASE_IMAGE : " mcr.microsoft.com/dotnet/aspnet:9.0"
23+ CONTAINER_REPOSITORY : " lancemccarthy/myaspnetcoreapp"
1724 WORKING_DIRECTORY : " src/AspNetCore/MyAspNetCoreApp"
1825 DOTNET_VERSION : " 9.0.x"
26+ NUGETCONFIG_PATH : " src/NuGet.Config"
1927
2028jobs :
2129 # #############################################
22- # ####### [Option A] DOCKER FILE BUILD ####### #
30+ # [Option A] DOCKERFILE BUILD #
2331 # #############################################
24- # => Publishes to registry.hub.docker.com <= #
32+ # Publishes to registry.hub.docker.com (Docker hub)
2533 build_aspnetcore :
2634 runs-on : ubuntu-22.04
2735 permissions :
@@ -33,19 +41,25 @@ jobs:
3341 with :
3442 fetch-depth : 0
3543
36- # Getting all my secrets from AKeyless is a personal choice , you can use GitHub Actions secrets instead.
44+ # Using AKeyless for secrets , you can use GitHub Actions instead.
3745 - name : Fetch secrets from AKeyless
3846 id : akeyless
3947 uses : LanceMcCarthy/akeyless-action@v3
4048 with :
4149 access-id : ${{secrets.AKEYLESS_JWT_ID}}
42- static-secrets : ' {"/personal-keys/mccarthy/TELERIK_NUGET_KEY":"TELERIK_NUGET_KEY", "/personal-keys/mccarthy/DOCKER_HUB_USERNAME":"DOCKER_HUB_USERNAME", "/personal-keys/mccarthy/DOCKER_HUB_PAT":"DOCKER_HUB_PAT"}'
50+ static-secrets : |
51+ {
52+ "/personal-keys/mccarthy/TELERIK_NUGET_KEY":"TELERIK_NUGET_KEY",
53+ "/personal-keys/mccarthy/TELERIK_LICENSE":"TELERIK_LICENSE_KEY",
54+ "/personal-keys/mccarthy/DOCKER_HUB_USERNAME":"DOCKER_HUB_USERNAME",
55+ "/personal-keys/mccarthy/DOCKER_HUB_PAT":"DOCKER_HUB_PAT"
56+ }
4357 export-secrets-to-outputs : true
4458 export-secrets-to-environment : false
4559
4660 - name : Create Kendo license file in the appropriate project directory
4761 run : |
48- cd src/AspNetCore/MyAspNetCoreApp /wwwroot/js
62+ cd ${{env.WORKING_DIRECTORY}} /wwwroot/js
4963 echo ${{steps.akeyless.outputs.KENDO_LICENSE_FILE}} > kendo-ui-license.js
5064
5165 - name : Set up QEMU
5872 id : meta
5973 uses : docker/metadata-action@v5
6074 with :
61- images : lancemccarthy/myaspnetcoreapp
75+ images : ${{env.CONTAINER_REPOSITORY}}
6276
6377 - name : Login to DockerHub
6478 uses : docker/login-action@v3
@@ -73,24 +87,29 @@ jobs:
7387 platforms : linux/arm64,linux/amd64
7488 push : true
7589 secrets : |
76- telerik_key=${{steps.akeyless.outputs.TELERIK_NUGET_KEY}}
90+ telerik-nuget-key=${{steps.akeyless.outputs.TELERIK_NUGET_KEY}}
91+ telerik-license-key=${{steps.akeyless.outputs.TELERIK_LICENSE_KEY}}
7792 tags : |
78- lancemccarthy/myaspnetcoreapp :latest
93+ ${{env.CONTAINER_REPOSITORY}} :latest
7994
8095
8196 # #########################################################
82- # ######## [Option B] .NET SDK CONTAINER BUILD ########### #
97+ # [Option B] .NET SDK CONTAINER BUILD #
8398 # #########################################################
84- # => Publishes to ghcr.io (GitHub container registry) <= #
85- build_x64 :
99+ # => Publishes to ghcr.io (GitHub)
100+ dotnet_container_build :
86101 runs-on : ubuntu-22.04
87- permissions :
88- contents : read
89- packages : write
102+ strategy :
103+ matrix :
104+ platform : [arm64, x64]
90105 outputs :
91- build_tag : ${{steps.build.outputs.build_tag}}
106+ tag_arm64 : ${{steps.build.outputs.build_tag_arm64}}
107+ tag_amd64 : ${{steps.build.outputs.build_tag_amd64}}
92108 env :
93- target_arch : " x64"
109+ CONTAINER_REGISTRY : " ghcr.io"
110+ TELERIK_USERNAME : " api-key"
111+ TELERIK_PASSWORD : ${{secrets.TELERIK_NUGET_KEY}}
112+ TELERIK_LICENSE : ${{secrets.TELERIK_LICENSE}}
94113 steps :
95114 - name : Checkout
96115 uses : actions/checkout@v4
@@ -103,88 +122,149 @@ jobs:
103122 dotnet-version : ${{env.DOTNET_VERSION}}
104123
105124 - name : Login to GitHub Container Registry
106- run : docker login ghcr.io -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
125+ run : docker login ${{env.CONTAINER_REGISTRY}} -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
107126
108127 - name : Restore NuGet Packages
109128 working-directory : ${{env.WORKING_DIRECTORY}}
110- run : dotnet restore -r "linux-${{env.target_arch}}" --configfile "../../NuGet.Config"
111- env :
112- TELERIK_USERNAME : " api-key"
113- TELERIK_PASSWORD : ${{secrets.TELERIK_NUGET_KEY}}
129+ run : dotnet restore -r "linux-${{matrix.platform}}" --configfile ${{env.NUGETCONFIG_PATH}}
114130
115- - name : build the x64 image
131+ - name : Build the platform image
116132 id : build
117133 working-directory : ${{env.WORKING_DIRECTORY}}
118134 run : |
119- TAG="latest-${{env.target_arch}}"
120-
121- # Build and publish arch-specific container
122- dotnet publish -t:PublishContainer -p PublishProfile=DefaultContainer --arch ${{env.target_arch}} -p ContainerImageTag="$TAG" -p ContainerRepository="lancemccarthy/myaspnetcoreapp" -p ContainerRegistry="ghcr.io" -p ContainerBaseImage=${{env.CONTAINER_BASE_IMAGE}} --no-restore
135+ # job output to reference this build later
136+ echo "tag_${{matrix.platform}}=${{matrix.platform}}" >> "$GITHUB_OUTPUT"
123137
124- # Job output the arch-specific container name so we can publish a multi-arch image later
125- echo "build_tag=$TAG" >> $GITHUB_OUTPUT
138+ dotnet publish -t:PublishContainer -p PublishProfile=DefaultContainer --arch ${{matrix.platform}} -p ContainerImageTag="latest-${{matrix.platform}}" -p ContainerRepository=${{env.CONTAINER_REPOSITORY}} -p ContainerRegistry=${{env.CONTAINER_REGISTRY}} -p ContainerBaseImage=${{env.CONTAINER_BASE_IMAGE}} --no-restore
126139
127- build_arm64 :
140+ publish_combined_manifest :
128141 runs-on : ubuntu-22.04
129- permissions :
130- contents : read
131- packages : write
132- outputs :
133- build_tag : ${{steps.build.outputs.build_tag}}
142+ needs : [dotnet_container_build]
134143 env :
135- target_arch : " arm64 "
144+ CONTAINER_REGISTRY : " ghcr.io "
136145 steps :
137146 - name : Checkout
138147 uses : actions/checkout@v4
139148 with :
140149 fetch-depth : 0
141150
142- - name : Setup .NET Core SDK
143- uses : actions/setup-dotnet@v4
144- with :
145- dotnet-version : ${{env.DOTNET_VERSION}}
146-
147151 - name : Login to GitHub Container Registry
148- run : docker login ghcr.io -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
152+ run : docker login ${{env.CONTAINER_REGISTRY}} -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
149153
150- - name : Restore NuGet Packages
151- working-directory : ${{env.WORKING_DIRECTORY}}
152- run : dotnet restore -r "linux-${{env.target_arch}}" --configfile "../../NuGet.Config"
153- env :
154- TELERIK_USERNAME : " api-key"
155- TELERIK_PASSWORD : ${{secrets.TELERIK_NUGET_KEY}}
154+ - name : Create multi-image manifest
155+ run : docker manifest create "${{env.CONTAINER_REGISTRY}}/${{env.CONTAINER_REPOSITORY}}:latest" \
156+ " ${{env.CONTAINER_REGISTRY}}/${{env.CONTAINER_REPOSITORY}}:${{needs.dotnet_container_build.outputs.tag_amd64}}" \
157+ " ${{env.CONTAINER_REGISTRY}}/${{env.CONTAINER_REPOSITORY}}:${{needs.dotnet_container_build.outputs.tag_arm64}}"
158+
159+ - name : Publish manifest
160+ run : docker manifest push "${{env.CONTAINER_REGISTRY}}/${{env.CONTAINER_REPOSITORY}}:latest"
156161
157- - name : build the arm64 image
158- id : build
159- working-directory : ${{env.WORKING_DIRECTORY}}
160- run : |
161- TAG="latest-${{env.target_arch}}"
162+ # # TODO - Remove this after confirming matrix strategy works
163+ # build_x64:
164+ # runs-on: ubuntu-22.04
165+ # permissions:
166+ # contents: read
167+ # packages: write
168+ # outputs:
169+ # build_tag: ${{steps.build.outputs.build_tag}}
170+ # env:
171+ # target_arch: "x64"
172+ # TELERIK_LICENSE: ${{secrets.TELERIK_LICENSE}}
173+ # steps:
174+ # - name: Checkout
175+ # uses: actions/checkout@v4
176+ # with:
177+ # fetch-depth: 0
162178
163- # Build and publish arch-specific container
164- dotnet publish -t:PublishContainer -p PublishProfile=DefaultContainer --arch ${{env.target_arch}} -p ContainerImageTag="$TAG" -p ContainerRepository="lancemccarthy/myaspnetcoreapp" -p ContainerRegistry="ghcr.io" -p ContainerBaseImage=${{env.CONTAINER_BASE_IMAGE}} --no-restore
179+ # - name: Setup .NET Core SDK
180+ # uses: actions/setup-dotnet@v4
181+ # with:
182+ # dotnet-version: ${{env.DOTNET_VERSION}}
165183
166- # Job output the arch-specific container name so we can publish a multi-arch image later
167- echo "build_tag=$TAG" >> $GITHUB_OUTPUT
184+ # - name: Login to GitHub Container Registry
185+ # run: docker login ghcr.io -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
168186
169- publish_combined_manifest :
170- runs-on : ubuntu-22.04
171- needs : [build_x64, build_arm64]
172- steps :
173- - name : Checkout
174- uses : actions/checkout@v4
175- with :
176- fetch-depth : 0
187+ # - name: Restore NuGet Packages
188+ # working-directory: ${{env.WORKING_DIRECTORY}}
189+ # run: dotnet restore -r "linux-${{env.target_arch}}" --configfile ${{env.NUGETCONFIG_PATH}}
190+ # env:
191+ # TELERIK_USERNAME: "api-key"
192+ # TELERIK_PASSWORD: ${{secrets.TELERIK_NUGET_KEY}}
177193
178- - name : Login to GitHub Container Registry
179- run : docker login ghcr.io -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
194+ # - name: build the x64 image
195+ # id: build
196+ # working-directory: ${{env.WORKING_DIRECTORY}}
197+ # run: |
198+ # TAG="latest-${{env.target_arch}}"
180199
181- - name : create the multi-image manifest
182- run : |
183- docker manifest create "ghcr.io/lancemccarthy/myaspnetcoreapp:latest" \
184- "ghcr.io/lancemccarthy/myaspnetcoreapp:$X86_TAG" \
185- "ghcr.io/lancemccarthy/myaspnetcoreapp:$ARM64_TAG"
200+ # # Build and publish arch-specific container
201+ # dotnet publish -t:PublishContainer -p PublishProfile=DefaultContainer --arch ${{env.target_arch}} -p ContainerImageTag="$TAG" -p ContainerRepository="lancemccarthy/myaspnetcoreapp" -p ContainerRegistry="ghcr.io" -p ContainerBaseImage=${{env.CONTAINER_BASE_IMAGE}} --no-restore
202+
203+ # # Job output the arch-specific container name so we can publish a multi-arch image later
204+ # echo "build_tag=$TAG" >> $GITHUB_OUTPUT
205+
206+ # build_arm64:
207+ # runs-on: ubuntu-22.04
208+ # permissions:
209+ # contents: read
210+ # packages: write
211+ # outputs:
212+ # build_tag: ${{steps.build.outputs.build_tag}}
213+ # env:
214+ # target_arch: "arm64"
215+ # TELERIK_LICENSE: ${{secrets.TELERIK_LICENSE}}
216+ # steps:
217+ # - name: Checkout
218+ # uses: actions/checkout@v4
219+ # with:
220+ # fetch-depth: 0
221+
222+ # - name: Setup .NET Core SDK
223+ # uses: actions/setup-dotnet@v4
224+ # with:
225+ # dotnet-version: ${{env.DOTNET_VERSION}}
226+
227+ # - name: Login to GitHub Container Registry
228+ # run: docker login ghcr.io -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
229+
230+ # - name: Restore NuGet Packages
231+ # working-directory: ${{env.WORKING_DIRECTORY}}
232+ # run: dotnet restore -r "linux-${{env.target_arch}}" --configfile ${{env.NUGETCONFIG_PATH}}
233+ # env:
234+ # TELERIK_USERNAME: "api-key"
235+ # TELERIK_PASSWORD: ${{secrets.TELERIK_NUGET_KEY}}
236+
237+ # - name: build the arm64 image
238+ # id: build
239+ # working-directory: ${{env.WORKING_DIRECTORY}}
240+ # run: |
241+ # TAG="latest-${{env.target_arch}}"
242+
243+ # # Build and publish arch-specific container
244+ # dotnet publish -t:PublishContainer -p PublishProfile=DefaultContainer --arch ${{env.target_arch}} -p ContainerImageTag="$TAG" -p ContainerRepository="lancemccarthy/myaspnetcoreapp" -p ContainerRegistry="ghcr.io" -p ContainerBaseImage=${{env.CONTAINER_BASE_IMAGE}} --no-restore
245+
246+ # # Job output the arch-specific container name so we can publish a multi-arch image later
247+ # echo "build_tag=$TAG" >> $GITHUB_OUTPUT
248+
249+ # publish_combined_manifest:
250+ # runs-on: ubuntu-22.04
251+ # needs: [build_x64, build_arm64]
252+ # steps:
253+ # - name: Checkout
254+ # uses: actions/checkout@v4
255+ # with:
256+ # fetch-depth: 0
257+
258+ # - name: Login to GitHub Container Registry
259+ # run: docker login ghcr.io -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
260+
261+ # - name: create the multi-image manifest
262+ # run: |
263+ # docker manifest create "ghcr.io/lancemccarthy/myaspnetcoreapp:latest" \
264+ # "ghcr.io/lancemccarthy/myaspnetcoreapp:$X86_TAG" \
265+ # "ghcr.io/lancemccarthy/myaspnetcoreapp:$ARM64_TAG"
186266
187- docker manifest push "ghcr.io/lancemccarthy/myaspnetcoreapp:latest"
188- env :
189- X86_TAG : ${{needs.build_x64.outputs.build_tag}}
190- ARM64_TAG : ${{needs.build_arm64.outputs.build_tag}}
267+ # docker manifest push "ghcr.io/lancemccarthy/myaspnetcoreapp:latest"
268+ # env:
269+ # X86_TAG: ${{needs.build_x64.outputs.build_tag}}
270+ # ARM64_TAG: ${{needs.build_arm64.outputs.build_tag}}
0 commit comments