@@ -8,6 +8,7 @@ ms.custom: github-actions-azure, devx-track-azurecli, linux-related-content
8
8
ms.devlang : azurecli
9
9
author : cephalin
10
10
ms.author : cephalin
11
+ zone_pivot_groups : app-service-containers-github-actions
11
12
---
12
13
13
14
# Deploy a custom container to App Service using GitHub Actions
@@ -182,6 +183,8 @@ Define secrets to use with the Docker Login action. The example in this document
182
183
183
184
# # Build the Container image
184
185
186
+ :: : zone pivot="github-actions-containers-linux"
187
+
185
188
The following example show part of the workflow that builds a Node.js Docker image. Use [Docker Login](https://github.com/azure/docker-login) to log into a private container registry. This example uses Azure Container Registry but the same action works for other registries.
186
189
187
190
@@ -234,6 +237,59 @@ jobs:
234
237
docker push mycontainer.azurecr.io/myapp:${{ github.sha }}
235
238
` ` `
236
239
240
+ :: : zone-end
241
+
242
+ :: : zone pivot="github-actions-containers-windows"
243
+
244
+ The following example shows part of the workflow that builds a Windows Docker image. Use [Docker Login](https://github.com/azure/docker-login) to log into a private container registry. This example uses Azure Container Registry but the same action works for other registries.
245
+
246
+
247
+ ` ` ` yaml
248
+ name: Windows Container Workflow
249
+ on: [push]
250
+ jobs:
251
+ build:
252
+ runs-on: windows-latest
253
+ steps:
254
+ - uses: actions/checkout@v2
255
+ - uses: azure/docker-login@v1
256
+ with:
257
+ login-server: mycontainer.azurecr.io
258
+ username: ${{ secrets.REGISTRY_USERNAME }}
259
+ password: ${{ secrets.REGISTRY_PASSWORD }}
260
+ - run: |
261
+ docker build . -t mycontainer.azurecr.io/myapp:${{ github.sha }}
262
+ docker push mycontainer.azurecr.io/myapp:${{ github.sha }}
263
+ ` ` `
264
+
265
+ You can also use [Docker sign-in](https://github.com/azure/docker-login) to log into multiple container registries at the same time. This example includes two new GitHub secrets for authentication with docker.io. The example assumes that there's a Dockerfile at the root level of the registry.
266
+
267
+ ` ` ` yml
268
+ name: Windows Container Workflow
269
+ on: [push]
270
+ jobs:
271
+ build:
272
+ runs-on: windows-latest
273
+ steps:
274
+ - uses: actions/checkout@v2
275
+ - uses: azure/docker-login@v1
276
+ with:
277
+ login-server: mycontainer.azurecr.io
278
+ username: ${{ secrets.REGISTRY_USERNAME }}
279
+ password: ${{ secrets.REGISTRY_PASSWORD }}
280
+ - uses: azure/docker-login@v1
281
+ with:
282
+ login-server: index.docker.io
283
+ username: ${{ secrets.DOCKERIO_USERNAME }}
284
+ password: ${{ secrets.DOCKERIO_PASSWORD }}
285
+ - run: |
286
+ docker build . -t mycontainer.azurecr.io/myapp:${{ github.sha }}
287
+ docker push mycontainer.azurecr.io/myapp:${{ github.sha }}
288
+ ` ` `
289
+
290
+ :: : zone-end
291
+
292
+
237
293
# # Deploy to an App Service container
238
294
239
295
To deploy your image to a custom container in App Service, use the `azure/webapps-deploy@v2` action. This action has seven parameters :
@@ -250,6 +306,8 @@ To deploy your image to a custom container in App Service, use the `azure/webapp
250
306
251
307
# [Publish profile](#tab/publish-profile)
252
308
309
+ :: : zone pivot="github-actions-containers-linux"
310
+
253
311
` ` ` yaml
254
312
name: Linux Container Node Workflow
255
313
@@ -362,6 +420,124 @@ jobs:
362
420
az logout
363
421
` ` `
364
422
423
+ :: : zone-end
424
+
425
+ :: : zone pivot="github-actions-containers-windows"
426
+
427
+ ` ` ` yaml
428
+ name: Windows_Container_Workflow
429
+
430
+ on: [push]
431
+
432
+ jobs:
433
+ build:
434
+ runs-on: windows-latest
435
+
436
+ steps:
437
+ - uses: actions/checkout@v2
438
+
439
+ - uses: azure/docker-login@v1
440
+ with:
441
+ login-server: mycontainer.azurecr.io
442
+ username: ${{ secrets.REGISTRY_USERNAME }}
443
+ password: ${{ secrets.REGISTRY_PASSWORD }}
444
+
445
+ - run: |
446
+ docker build . -t mycontainer.azurecr.io/myapp:${{ github.sha }}
447
+ docker push mycontainer.azurecr.io/myapp:${{ github.sha }}
448
+
449
+ - uses: azure/webapps-deploy@v2
450
+ with:
451
+ app-name: 'myapp'
452
+ publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
453
+ images: 'mycontainer.azurecr.io/myapp:${{ github.sha }}'
454
+ ` ` `
455
+
456
+ # [Service principal](#tab/service-principal)
457
+
458
+ ` ` ` yaml
459
+ on: [push]
460
+
461
+ name: Windows_Container_Workflow
462
+
463
+ jobs:
464
+ build-and-deploy:
465
+ runs-on: windows-latest
466
+ steps:
467
+ # checkout the repo
468
+ - name: 'Checkout GitHub Action'
469
+ uses: actions/checkout@main
470
+
471
+ - name: 'Sign in via Azure CLI'
472
+ uses: azure/login@v1
473
+ with:
474
+ creds: ${{ secrets.AZURE_CREDENTIALS }}
475
+
476
+ - uses: azure/docker-login@v1
477
+ with:
478
+ login-server: mycontainer.azurecr.io
479
+ username: ${{ secrets.REGISTRY_USERNAME }}
480
+ password: ${{ secrets.REGISTRY_PASSWORD }}
481
+ - run: |
482
+ docker build . -t mycontainer.azurecr.io/myapp:${{ github.sha }}
483
+ docker push mycontainer.azurecr.io/myapp:${{ github.sha }}
484
+
485
+ - uses: azure/webapps-deploy@v2
486
+ with:
487
+ app-name: 'myapp'
488
+ images: 'mycontainer.azurecr.io/myapp:${{ github.sha }}'
489
+
490
+ - name: Azure logout
491
+ run: |
492
+ az logout
493
+ ` ` `
494
+
495
+ # [OpenID Connect](#tab/openid)
496
+
497
+ ` ` ` yaml
498
+ on: [push]
499
+ name: Windows_Container_Workflow
500
+
501
+ permissions:
502
+ id-token: write
503
+ contents: read
504
+
505
+ jobs:
506
+ build-and-deploy:
507
+ runs-on: windows-latest
508
+ steps:
509
+ # checkout the repo
510
+ - name: 'Checkout GitHub Action'
511
+ uses: actions/checkout@main
512
+
513
+ - name: 'Sign in via Azure CLI'
514
+ uses: azure/login@v1
515
+ with:
516
+ client-id: ${{ secrets.AZURE_CLIENT_ID }}
517
+ tenant-id: ${{ secrets.AZURE_TENANT_ID }}
518
+ subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
519
+
520
+ - uses: azure/docker-login@v1
521
+ with:
522
+ login-server: mycontainer.azurecr.io
523
+ username: ${{ secrets.REGISTRY_USERNAME }}
524
+ password: ${{ secrets.REGISTRY_PASSWORD }}
525
+ - run: |
526
+ docker build . -t mycontainer.azurecr.io/myapp:${{ github.sha }}
527
+ docker push mycontainer.azurecr.io/myapp:${{ github.sha }}
528
+
529
+ - uses: azure/webapps-deploy@v2
530
+ with:
531
+ app-name: 'myapp'
532
+ images: 'mycontainer.azurecr.io/myapp:${{ github.sha }}'
533
+
534
+ - name: Azure logout
535
+ run: |
536
+ az logout
537
+ ` ` `
538
+
539
+ :: : zone-end
540
+
365
541
---
366
542
367
543
# # Next steps
0 commit comments