-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
76 lines (65 loc) · 2.06 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
70
71
72
73
74
75
76
trigger:
branches:
include:
- 'main' # must quote since "*" is a YAML reserved character; we want a string
paths:
include:
- '*'
exclude:
- '**/*.md'
- docs
pool:
vmImage: 'ubuntu-latest'
variables:
- name: tagName
value: "$(Build.BuildNumber)"
- name: serviceName
value: "notification-service"
- name: latestImageName
value: "openreservation/$(serviceName):latest"
- name: imageName
value: "openreservation/$(serviceName):$(tagName)"
- group: "docker"
- group: "notification"
steps:
- task: UseDotNet@2
displayName: 'Use .NET sdk'
inputs:
packageType: sdk
version: 9.0.x
includePreviewVersions: true
- script: |
dotnet tool update -g dotnet-execute
export PATH="$PATH:$HOME/.dotnet/tools"
dotnet-exec info
displayName: 'dotnet-exec info'
- script: dotnet build -c Release
displayName: 'dotnet build'
- script: dotnet test
displayName: 'dotnet test'
- script: docker build -f ./OpenReservation.Notification/Dockerfile -t $(imageName) -t $(latestImageName) .
displayName: 'Docker build Script'
- script: |
docker login -u $(dockerId) -p $(pswd)
docker push $(imageName)
docker push $(latestImageName)
displayName: 'Push docker image'
- task: Kubernetes@1
displayName: 'kubectl update deployment'
inputs:
kubernetesServiceEndpoint: 'aks-hk-01'
command: 'apply'
arguments: '-f https://raw.githubusercontent.com/OpenReservation/OpenReservation.Notification/main/k8s/manifests/deployment.yaml'
- task: Kubernetes@1
displayName: 'kubectl set image'
inputs:
kubernetesServiceEndpoint: 'aks-hk-01'
command: 'set'
arguments: 'image deployment/$(serviceName) $(serviceName)=$(imageName)'
- script: |
dotnet-exec "https://github.com/OpenReservation/scripts/blob/main/deploy/azure-pipelines-notification.cs"
displayName: 'Push notification'
env:
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables
# can not directly reference a secret value
DingBotWebhookUrl: $(DingBotWebhookUrl)