Skip to content

Update policyinitiativebuilder.yml #1

Update policyinitiativebuilder.yml

Update policyinitiativebuilder.yml #1

name: Build and deploy .NET application to container app policyinitiativebuilder
on:
push:
branches:
- master
env:
CONTAINER_APP_CONTAINER_NAME: policyinitiativebuilder
CONTAINER_APP_NAME: policyinitiativebuilder
CONTAINER_APP_RESOURCE_GROUP_NAME: rg-policy-initiative-builder
CONTAINER_REGISTRY_LOGIN_SERVER: policyinitiativebuilder.azurecr.io
DOTNET_CORE_VERSION: 9.0.x
PROJECT_NAME_FOR_DOCKER: policyinitiativebuilder
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout to the branch
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1.8.0
with:
include-prerelease: True
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Log in to container registry
uses: azure/docker-login@v2
with:
login-server: ${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.PolicyInitiativeBuilder_USERNAME_31DD }}
password: ${{ secrets.PolicyInitiativeBuilder_PASSWORD_31DD }}
- name: Build and push container image to registry
run: dotnet publish -c Release -r linux-x64 -p:PublishProfile=DefaultContainer -p:ContainerImageTag=${{ github.sha }} --no-self-contained -p:ContainerRegistry=${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }} -bl
- name: Upload binlog for investigation
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: binlog
path: msbuild.binlog
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.policyinitiativebuilder_SPN }}
- name: Deploy to containerapp
uses: azure/CLI@v2
with:
inlineScript: >
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp registry set --name ${{ env.CONTAINER_APP_NAME }} --resource-group ${{ env.CONTAINER_APP_RESOURCE_GROUP_NAME }} --server ${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }} --username ${{ secrets.PolicyInitiativeBuilder_USERNAME_31DD }} --password ${{ secrets.PolicyInitiativeBuilder_PASSWORD_31DD }}
az containerapp update --name ${{ env.CONTAINER_APP_NAME }} --container-name ${{ env.CONTAINER_APP_CONTAINER_NAME }} --resource-group ${{ env.CONTAINER_APP_RESOURCE_GROUP_NAME }} --image ${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:${{ github.sha }}
- name: logout
run: >
az logout