Skip to content

Build and deploy .NET application to container app discordbotabordelv2-app-20230528 #17

Build and deploy .NET application to container app discordbotabordelv2-app-20230528

Build and deploy .NET application to container app discordbotabordelv2-app-20230528 #17

Workflow file for this run

name: Build and deploy .NET application to container app discordbotabordelv2-app-20230528
on:
release:
types: [published]
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
DOCKER_FILE_PATH: ./Discord.BotABordelV2/Dockerfile
PROJECT_NAME_FOR_DOCKER: discordbotabordelv2
jobs:
build:
runs-on: ubuntu-latest
environment: PROD
steps:
- name: Checkout to the branch
uses: actions/checkout@v3
- name: "Login via Azure CLI"
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID}}
tenant-id: ${{ secrets.AZURE_TENANT_ID}}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
- name: Build and push container image to registry
uses: azure/CLI@v1
with:
inlineScript: >
az acr build -t ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:2.1.0 -t ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:latest --registry ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }} --file ${{ env.DOCKER_FILE_PATH }} .
deploy:
runs-on: ubuntu-latest
needs: build
environment: PROD
steps:
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID}}
tenant-id: ${{ secrets.AZURE_TENANT_ID}}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
# - name: Configure Container App for Managed ID pulls
# uses: azure/CLI@v1
# with:
# inlineScript: >
# az config set extension.use_dynamic_install=yes_without_prompt
# az containerapp registry set --name ${{ vars.CONTAINER_APP_NAME }} --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} --server ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }} --identity system
# az containerapp update --name ${{ vars.CONTAINER_APP_NAME }} --container-name ${{ vars.CONTAINER_APP_CONTAINER_NAME }} --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} --image ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:${{ github.ref_name }}
- name: Deploy Image
uses: azure/container-apps-deploy-action@v1
with:
acrName: ${{ vars.CONTAINER_REGISTRY_NAME }}
containerAppName: ${{ vars.CONTAINER_APP_NAME }}
resourceGroup: ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }}
imageToDeploy: ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:${{ github.ref_name }}
- name: logout
run: >
az logout