-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (33 loc) · 1.21 KB
/
build-dotnet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Build .Net Docker image
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
BASE_PATH: . # The base path for the project files
VERSION_MAJOR: 1 # The major version
VERSION_MINOR: 0 # The minor version
DOCKER_FILE: Dockerfile # The docker file name
CONTAINER_REGISTRY: thomiles.azurecr.io # The docker image registry
jobs:
build-dotnet:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Login to ACR
uses: docker/login-action@v1
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ secrets.AZURE_CLIENT_ID }}
password: ${{ secrets.AZURE_CLIENT_SECRET }}
- name: Build and push
env:
DOCKER_TAG: "${{ env.VERSION_MAJOR }}.${{ env.VERSION_MINOR }}.${{ github.run_number }}"
DOCKER_IMAGE: "${{ env.CONTAINER_REGISTRY }}/${{ github.repository }}" # The image to build
run: |
docker pull $DOCKER_IMAGE:latest || true
docker build --cache-from $DOCKER_IMAGE:latest --tag $DOCKER_IMAGE:$DOCKER_TAG --tag $DOCKER_IMAGE:latest -f $DOCKER_FILE ./$BASE_PATH
docker push $DOCKER_IMAGE:$DOCKER_TAG
docker push $DOCKER_IMAGE:latest