-
Notifications
You must be signed in to change notification settings - Fork 89
/
azure-pipelines.yml
69 lines (57 loc) · 1.86 KB
/
azure-pipelines.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
trigger:
branches:
include:
- '*' # must quote since "*" is a YAML reserved character; we want a string
paths:
include:
- '*'
exclude:
- '**/*.md'
- /OpenReservation.Clients/
- /OpenReservation.API.Test/
- /OpenReservation.SourceGeneratorTest/
- /docs/
- /k8s/
pool:
vmImage: 'ubuntu-latest'
variables:
tagName: '$(Build.BuildNumber)'
repoName: 'reservation-server'
stableImageName: 'openreservation/$(repoName):stable'
latestImageName: 'openreservation/$(repoName):latest'
branchImageName: 'openreservation/$(repoName):$(Build.SourceBranchName)'
imageName: 'openreservation/$(repoName):$(tagName)'
steps:
- task: UseDotNet@2
displayName: 'Use .NET sdk'
inputs:
packageType: sdk
version: 8.0.x
- script: dotnet --info
displayName: 'dotnet info'
- script: dotnet build -c Release
displayName: 'dotnet build'
- script: dotnet test
displayName: 'dotnet test'
- script: docker build -f Dockerfile -t $(imageName) -t $(branchImageName) -t $(latestImageName) -t $(stableImageName) .
displayName: 'Docker build Script'
- script: |
docker login -u $(dockerId) -p $(pswd)
docker push $(imageName)
docker push $(branchImageName)
displayName: 'Push docker image'
- script: |
docker push $(latestImageName)
displayName: 'Push latest image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))
- script: docker push $(stableImageName)
displayName: 'Push stable image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: SSH@0
displayName: 'Run shell inline on remote machine'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))
inputs:
sshEndpoint: 'weihanli-vm'
runOptions: inline
inline: |
kubectl set image deployment/reservation-server reservation-server=$(imageName)