-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
121 lines (106 loc) · 3.81 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Docker
# Build a Docker image
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: SyncToGithub
displayName: Sync to GitHub
pool: default
steps:
- task: CmdLine@2
inputs:
script: |
git checkout master
git pull https://$(DEVOPSACCESSTOKEN)@dev.azure.com/3dextended/YetAnotherbot/_git/YetAnotherbot master
git pull https://$(GITHUBACCESSTOKEN)@github.com/3DExtended/YetAnotherBot.git master
git status
git push https://$(DEVOPSACCESSTOKEN)@dev.azure.com/3dextended/YetAnotherbot/_git/YetAnotherbot
git push https://$(GITHUBACCESSTOKEN)@github.com/3DExtended/YetAnotherBot.git
- job: Build
displayName: Build
pool: Tower DOCKER
steps:
- task: CmdLine@2
displayName: Cleanup and delete all images on machine
enabled: true
inputs:
script: |
sudo docker system prune --all -f
- task: DockerInstaller@0
displayName: Install Docker 20.X
inputs:
dockerVersion: '20.10.7'
- task: Docker@2
displayName: Login to docker registry
inputs:
containerRegistry: '3dextended registry azure'
command: 'login'
- task: CmdLine@2
displayName: Build image for platform linux/arm/v7
enabled: true
inputs:
script: |
docker --version
sudo docker run --privileged --rm tonistiigi/binfmt --install all
sudo docker buildx use ci-builder
sudo docker buildx inspect --bootstrap
sudo docker buildx build -t 3dextended/yetanotherbot:$(tag)raspberrypi -t 3dextended/yetanotherbot:latestraspberrypi -t 3dextended.azurecr.io/yetanotherbot:$(tag)raspberrypi -t 3dextended.azurecr.io/yetanotherbot:latestraspberrypi . --platform linux/arm/v7
sudo docker buildx build -t 3dextended/yetanotherbot:latest -t 3dextended/yetanotherbot:$(tag) -t 3dextended.azurecr.io/yetanotherbot:$(tag) -t 3dextended.azurecr.io/yetanotherbot:latest . --platform linux/amd64
- task: Docker@2
displayName: push custom platform version of image
inputs:
containerRegistry: '3dextended registry azure'
repository: 'yetanotherbot'
command: 'push'
tags: |
$(tag)raspberrypi
latestraspberrypi
- task: Docker@2
displayName: push custom platform version of image
inputs:
containerRegistry: '3dextended registry azure'
repository: 'yetanotherbot'
command: 'push'
tags: |
$(tag)
latest
- task: Docker@2
inputs:
containerRegistry: 'Dockerhub 3DExtended'
command: 'login'
- task: Docker@2
enabled: false
inputs:
containerRegistry: 'Dockerhub 3DExtended'
command: 'push'
repository: '3dextended/yetanotherbot'
tags: |
3dextended/yetanotherbot:$(tag)raspberrypi
3dextended/yetanotherbot:latestraspberrypi
3dextended/yetanotherbot:$(tag)
3dextended/yetanotherbot:latest
- task: CmdLine@2
displayName: Push images to dockerhub
enabled: true
inputs:
script: |
docker --version
sudo docker login -u 3dextended -p $(DOCKERHUBPASSWORD)
sudo docker push 3dextended/yetanotherbot:$(tag)raspberrypi
sudo docker push 3dextended/yetanotherbot:latestraspberrypi
sudo docker push 3dextended/yetanotherbot:$(tag)
sudo docker push 3dextended/yetanotherbot:latest
- task: CmdLine@2
displayName: Cleanup and delete all images on machine
enabled: true
inputs:
script: |
sudo docker system prune --all -f