-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
68 lines (65 loc) · 2.09 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
pool:
vmImage: 'ubuntu-latest'
name: $(BuildID)-$(Build.SourceBranchName)
variables:
${{ if notIn(variables['Build.SourceBranch'], 'refs/heads/main') }}:
buildImage: false
deployService: false
deployEnvironment: 'none'
imageName: 'none'
imageTags: 'none'
proxyServiceName: schedule-rtu_bot
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
buildImage: true
deployService: true
deployEnvironment: production
imageName: 'rtuitlab/schedule-rtu-bot'
imageTags: |
$(Build.BuildId)
latest
proxyServiceName: schedule-rtu_bot
stages:
- stage: build
condition: and(succeeded(), ${{variables.buildImage}})
jobs:
- job: packApi
displayName: Pack docker image
steps:
- task: Docker@2
displayName: buildAndPush
inputs:
containerRegistry: 'rtuitlab connection by admin'
repository: ${{variables.imageName}}
command: 'buildAndPush'
Dockerfile: './Dockerfile'
buildContext: './'
tags: ${{variables.imageTags}}
- stage: deploy
condition: and(succeeded(), ${{variables.deployService}})
jobs:
- deployment: DeployBot
displayName: Deploy bot
pool:
vmImage: 'ubuntu-latest'
environment: ${{variables.deployEnvironment}}
strategy:
runOnce:
on:
failure:
steps:
- download: none
- task: SSH@0
inputs:
sshEndpoint: 'swarm manager'
runOptions: 'commands'
commands: 'docker service rollback ${{variables.proxyServiceName}}'
readyTimeout: '20000'
deploy:
steps:
- download: none
- task: SSH@0
inputs:
sshEndpoint: 'swarm manager'
runOptions: 'commands'
commands: 'docker service update --image ${{variables.imageName}}:$(Build.BuildId) ${{variables.proxyServiceName}} --with-registry-auth'
readyTimeout: '20000'