- Published on
Azure Container Apps (ACA) allows you to use GitHub Actions to publish new revisions to your container app. As commits are pushed to your GitHub repository, a workflow is triggered which updates the container image in the container registry. Azure Container Apps creates a new revision based on the updated container image.
I used to using the azure/container-apps-deploy-action@v1 for build and deploy the Docker image with Azure Container Registry (ACR) and ACA However, in the latest design, I need to use a ACA have 2 containers. First one is app image and second one is sidecar image to forward logs. The Github action was working before I've added sidecar but it does not support for specifying the container name.
I checked the Github repo and found that it is still working in progress (at 2024 Apr 16)
https://github.com/Azure/container-apps-deploy-action/pull/79
So I decide to change the Github Action to use the azure/cli@v2 instead
The main idea is call CLI to update only the Docker image of the container. Ex,
yamlaz containerapp update \--name sample-app \--resource-group sample-app-rg \--image sampleapps.azurecr.io/sample-app:latest \--container-name main
The steps are
The full workflow yaml
yamlname: Trigger auto deployment for sample-appon:push:branches: [develop]paths:- '**'- '.github/workflows/sample-app-release.yml'workflow_dispatch:jobs:build-and-deploy:runs-on: ubuntu-latestpermissions:id-token: write #This is required for requesting the OIDC JWT Tokencontents: read #Required when GH token is used to authenticate with private reposteps:- name: Checkout to the branchuses: actions/checkout@v2- name: Azure Loginuses: azure/login@v1with:client-id: ${{ secrets.SAMPLEAPP_AZURE_CLIENT_ID }}tenant-id: ${{ secrets.SAMPLEAPP_AZURE_TENANT_ID }}subscription-id: ${{ secrets.SAMPLEAPP_AZURE_SUBSCRIPTION_ID }}- name: 'Docker login'uses: docker/login-action@v3with:registry: sampleapps.azurecr.iousername: ${{ secrets.SAMPLEAPP_REGISTRY_USERNAME }}password: ${{ secrets.SAMPLEAPP_REGISTRY_PASSWORD }}- name: 'Build and push image'run: |docker build . -t sampleapps.azurecr.io/sample-app:${{ github.sha }}docker push sampleapps.azurecr.io/sample-app:${{ github.sha }}docker tag sampleapps.azurecr.io/sample-app:${{ github.sha }} sampleapps.azurecr.io/sample-app:latestdocker push sampleapps.azurecr.io/sample-app:latest- name: Deploy to Azure Container Appsuses: azure/cli@v2with:inlineScript: |az containerapp update \--name sample-app \--resource-group sample-app-rg \--image sampleapps.azurecr.io/sample-app:latest \--container-name main
- Published on