forked from Jamesits/docker-dst-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yaml
207 lines (184 loc) · 6.03 KB
/
azure-pipelines.yaml
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: $(Date:yyyyMMdd).$(Rev:r)
variables:
DOCKER_IMAGE_BASENAME: "jamesits/dst-server"
trigger:
batch: true
branches:
include: [ "master" ]
paths:
include: [ "*" ]
exclude: [ "README.md" ]
pr:
autoCancel: true
branches:
include:
- master
paths:
exclude:
- README.md
schedules:
- cron: "0 3 * * *"
displayName: nightly build
always: true
branches:
include:
- master
jobs:
# code style check
- job: code_check
displayName: "check"
pool:
vmImage: "ubuntu-latest"
workspace:
clean: all
timeoutInMinutes: 10
condition: ne(variables['Build.Reason'], 'Schedule')
steps:
- checkout: self
clean: true
submodules: true
- bash: |
sudo apt-get update -y
sudo apt-get install -y shellcheck
displayName: "Install build dependencies"
- bash: |
shellcheck scripts_system/*
displayName: "shellcheck"
continueOnError: true
# different variants
- job: docker
displayName: "docker build"
pool:
vmImage: "ubuntu-latest"
workspace:
clean: all
timeoutInMinutes: 40
condition: ne(variables['Build.Reason'], 'Schedule')
strategy:
matrix:
vanilla_debian_buster:
DOCKER_TAGS: 'latest vanilla'
BASE_IMAGE: 'debian:buster-slim'
DST_DOWNLOAD: '1'
DST_USER: 'dst'
DST_GROUP: 'dst'
STEAMCMD_PATH: '/opt/steamcmd/steamcmd.sh'
vanilla_debian_buster_slim:
DOCKER_TAGS: 'latest-slim vanilla-slim'
BASE_IMAGE: 'debian:buster-slim'
DST_DOWNLOAD: '0'
DST_USER: 'dst'
DST_GROUP: 'dst'
STEAMCMD_PATH: '/opt/steamcmd/steamcmd.sh'
vanilla_debian_bullseye_slim: # experimental
BASE_IMAGE: 'debian:bullseye-slim'
DST_DOWNLOAD: '0'
DST_USER: 'dst'
DST_GROUP: 'dst'
STEAMCMD_PATH: '/opt/steamcmd/steamcmd.sh'
cm2network_steamcmd:
DOCKER_TAGS: 'steamcmd-rebase'
BASE_IMAGE: 'cm2network/steamcmd:root'
DST_DOWNLOAD: '1'
DST_USER: 'steam'
DST_GROUP: 'steam'
STEAMCMD_PATH: '/home/steam/steamcmd/steamcmd.sh'
cm2network_steamcmd_slim:
DOCKER_TAGS: 'steamcmd-rebase-slim'
BASE_IMAGE: 'cm2network/steamcmd:root'
DST_DOWNLOAD: '0'
DST_USER: 'steam'
DST_GROUP: 'steam'
STEAMCMD_PATH: '/home/steam/steamcmd/steamcmd.sh'
steamcmd_steamcmd: # verification only
BASE_IMAGE: 'steamcmd/steamcmd:ubuntu'
DST_DOWNLOAD: '1'
DST_USER: 'dst'
DST_GROUP: 'dst'
STEAMCMD_PATH: '/usr/games/steamcmd'
steamcmd_steamcmd_slim: # verification only
BASE_IMAGE: 'steamcmd/steamcmd:ubuntu'
DST_DOWNLOAD: '0'
DST_USER: 'dst'
DST_GROUP: 'dst'
STEAMCMD_PATH: '/usr/games/steamcmd'
steps:
- checkout: self
clean: true
submodules: true
- bash: |
set -Eeuo pipefail
docker build -t dst \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
--build-arg STEAMCMD_PATH=$(STEAMCMD_PATH) \
--build-arg DST_DOWNLOAD=$(DST_DOWNLOAD) \
--build-arg DST_USER=$(DST_USER) \
--build-arg DST_GROUP=$(DST_GROUP) \
.
docker images --digests dst
displayName: "Build image"
- task: Docker@1
displayName: "Docker login"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: "Docker Hub: Jamesits"
command: login
- bash: |
set -Eeuo pipefail
if [ -z "$(DOCKER_TAGS)" ]; then
echo "No tags to push"
exit 0
fi
IFS=' ' read -ra TAGS <<< "$(DOCKER_TAGS)"
for TAG in "${TAGS[@]}"; do
echo "Tagging $(DOCKER_IMAGE_BASENAME):${TAG}"
docker tag dst $(DOCKER_IMAGE_BASENAME):${TAG}
docker push $(DOCKER_IMAGE_BASENAME):${TAG}
done
displayName: "Push image"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
- task: Docker@1
displayName: "Docker logout"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: "Docker Hub: Jamesits"
command: logout
# a vanilla image with all default build arguments
- job: docker_nightly
displayName: "docker build nightly"
pool:
vmImage: "ubuntu-latest"
workspace:
clean: all
timeoutInMinutes: 40
steps:
- checkout: self
clean: true
submodules: true
- bash: |
set -Eeuo pipefail
docker build -t dst .
docker images --digests dst
displayName: "Build image"
- task: Docker@1
displayName: "Docker login"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: "Docker Hub: Jamesits"
command: login
- bash: |
set -Eeuo pipefail
docker tag dst $(DOCKER_IMAGE_BASENAME):nightly
docker push $(DOCKER_IMAGE_BASENAME):nightly
displayName: "Push image"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
- task: Docker@1
displayName: "Docker logout"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: "Docker Hub: Jamesits"
command: logout