Skip to content

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

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

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

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: Set up container secrets
uses: azure/CLI@v1
with:
inlineScript: >
az containerapp secret set \
--name ${{ vars.CONTAINER_APP_NAME }} \
--resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} \
--secrets 'discordbot-token=${{ secrets.DISCORD_BOT_TOKEN }}'
- name: Deploy to container app
uses: azure/CLI@v1
with:
inlineScript: >
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 }} \
--resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} \
--image ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:2.1.0
- name: logout
run: >
az logout