Build and push the latest build to staging #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push the latest build to staging | |
# This workflow will build a docker container, publish it to Azure Container Registry, and deploy it to Azure Kubernetes Service. | |
# | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Restore dependencies | |
working-directory: ./API/ | |
run: dotnet restore | |
- name: Build | |
working-directory: ./API/ | |
run: dotnet build --no-restore | |
docker: | |
name: Docker Build & Push to ACR | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Connect to Azure Container registry (ACR) | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ secrets.ACR_LOGIN }} | |
username: ${{ secrets.ACR_NAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Build Image without DockerFile using Microsoft.NET.Build.Containers | |
working-directory: ./API/ | |
run: dotnet publish --os linux --arch x64 -c Release -p:ContainerImageName=${{ secrets.ACR_LOGIN }}/api-template-image | |
- name: Push Image | |
run: docker push ${{ secrets.ACR_LOGIN }}/api-template-image --all-tags |