-
Notifications
You must be signed in to change notification settings - Fork 1
313 lines (308 loc) · 11 KB
/
build.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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: build
on:
push:
branches:
- master
tags:
- '**'
pull_request:
branches:
- master
jobs:
alpine:
runs-on: ubuntu-latest
strategy:
matrix:
OS: [alpine]
OS_VARIANT: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13', '3.14', '3.15', '3.16', '3.17', '3.18', '3.19', edge]
include:
- OS: alpine
OS_VARIANT: 3.8
BASE_IMAGE_TAG: 3.8
ANSIBLE_VERSION: 2.6.20
- OS: alpine
OS_VARIANT: 3.9
BASE_IMAGE_TAG: 3.9
ANSIBLE_VERSION: 2.7.17
- OS: alpine
OS_VARIANT: 3.10
BASE_IMAGE_TAG: '3.10'
ANSIBLE_VERSION: 2.8.19
- OS: alpine
OS_VARIANT: 3.11
BASE_IMAGE_TAG: '3.11'
ANSIBLE_VERSION: 2.9.18
- OS: alpine
OS_VARIANT: 3.12
BASE_IMAGE_TAG: '3.12'
ANSIBLE_VERSION: 2.9.18
- OS: alpine
OS_VARIANT: 3.13
BASE_IMAGE_TAG: '3.13'
ANSIBLE_VERSION: 2.10.7
- OS: alpine
OS_VARIANT: 3.14
BASE_IMAGE_TAG: '3.14'
ANSIBLE_VERSION: 2.10.7
- OS: alpine
OS_VARIANT: 3.15
BASE_IMAGE_TAG: '3.15'
ANSIBLE_VERSION: 4.8.0
- OS: alpine
OS_VARIANT: 3.16
BASE_IMAGE_TAG: '3.16'
ANSIBLE_VERSION: 5.8.0
- OS: alpine
OS_VARIANT: 3.17
BASE_IMAGE_TAG: '3.17'
ANSIBLE_VERSION: 6.6.0
- OS: alpine
OS_VARIANT: 3.18
BASE_IMAGE_TAG: '3.18'
ANSIBLE_VERSION: 7.5.0
TAG_OS: true
TAG_LATEST: true
- OS: alpine
OS_VARIANT: 3.19
BASE_IMAGE_TAG: '3.19'
ANSIBLE_VERSION: 8.6.1
- OS: alpine
OS_VARIANT: edge
BASE_IMAGE_TAG: edge
ANSIBLE_VERSION: 9.3.0
env:
OS: ${{ matrix.OS }}
OS_VARIANT: ${{ matrix.OS_VARIANT }}
ANSIBLE_VERSION: ${{ matrix.ANSIBLE_VERSION }}
TAG_OS: ${{ matrix.TAG_OS }}
TAG_LATEST: ${{ matrix.TAG_LATEST }}
BASE_REGISTRY_NAMESPACE: library
BASE_IMAGE_NAME: ${{ matrix.OS }}
BASE_TAG_FULL: ${{ matrix.BASE_IMAGE_TAG }}
BUILD_REGISTRY_NAMESPACE: ${{ vars.DOCKERHUB_REGISTRY_USER }}
BUILD_IMAGE_NAME: ansible
BUILD_TAG_FULL: ${{ matrix.ANSIBLE_VERSION }}-${{ matrix.OS }}-${{ matrix.OS_VARIANT }}
BUILD_CONTEXT: variants/${{ matrix.OS }}/${{ matrix.OS_VARIANT }}
steps:
- uses: actions/checkout@v3
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
docker info
docker version
- name: Login to docker registry
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
env:
DOCKERHUB_REGISTRY_USER: ${{ vars.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
- name: Build image
run: |
set -e
echo "OS: $OS"
echo "OS_VARIANT: $OS_VARIANT"
echo "ANSIBLE_VERSION: $ANSIBLE_VERSION"
echo "TAG_OS: $TAG_OS"
echo "TAG_LATEST: $TAG_LATEST"
echo "BASE_REGISTRY_NAMESPACE: $BASE_REGISTRY_NAMESPACE"
echo "BASE_IMAGE_NAME: $BASE_IMAGE_NAME"
echo "BASE_TAG_FULL: $BASE_TAG_FULL"
echo "BUILD_REGISTRY_NAMESPACE: $BUILD_REGISTRY_NAMESPACE"
echo "BUILD_IMAGE_NAME: $BUILD_IMAGE_NAME"
echo "BUILD_TAG_FULL: $BUILD_TAG_FULL"
echo "BUILD_CONTEXT: $BUILD_CONTEXT"
echo "BASE_IMAGE: ${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL}"
echo "BUILD_IMAGE: ${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}"
time docker pull "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" || true
time docker build \
--cache-from "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" \
-t "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" \
--build-arg BASE_IMAGE="${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL}" \
"$BUILD_CONTEXT"
if [ "${TAG_OS}" = 'true' ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${OS}"
fi
if [ "${TAG_LATEST}" = 'true' ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:latest"
fi
docker images
docker inspect "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}"
- name: Test image
run: docker run -t --rm "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" ansible --version
- name: Push image
if: startsWith(github.ref, 'refs/tags/')
run: docker push -a "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}"
- name: Clean-up
run: docker logout
if: always()
ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
OS: [ubuntu]
OS_VARIANT: [16.04, 18.04, 20.04, 22.04]
PACKAGE_TYPE: [default, ppa]
include:
- OS: ubuntu
OS_VARIANT: 16.04
BASE_IMAGE_TAG: 16.04
- OS: ubuntu
OS_VARIANT: 18.04
BASE_IMAGE_TAG: 18.04
- OS: ubuntu
OS_VARIANT: 20.04
BASE_IMAGE_TAG: 20.04
- OS: ubuntu
OS_VARIANT: 22.04
BASE_IMAGE_TAG: 22.04
- OS: ubuntu
OS_VARIANT: 16.04
PACKAGE_TYPE: default
ANSIBLE_VERSION: 2.1.1.0
- OS: ubuntu
OS_VARIANT: 18.04
PACKAGE_TYPE: default
ANSIBLE_VERSION: 2.5.1
- OS: ubuntu
OS_VARIANT: 20.04
PACKAGE_TYPE: default
ANSIBLE_VERSION: 2.9.6
- OS: ubuntu
OS_VARIANT: 22.04
PACKAGE_TYPE: default
ANSIBLE_VERSION: 2.10.7
- OS: ubuntu
OS_VARIANT: 16.04
PACKAGE_TYPE: ppa
SUFFIX_PPA: -ppa
ANSIBLE_VERSION: 2.9.27
- OS: ubuntu
OS_VARIANT: 18.04
PACKAGE_TYPE: ppa
SUFFIX_PPA: -ppa
ANSIBLE_VERSION: 2.9.27
- OS: ubuntu
OS_VARIANT: 20.04
PACKAGE_TYPE: ppa
SUFFIX_PPA: -ppa
ANSIBLE_VERSION: 5.10.0
TAG_OS: true
- OS: ubuntu
OS_VARIANT: 22.04
PACKAGE_TYPE: ppa
SUFFIX_PPA: -ppa
ANSIBLE_VERSION: 9.3.0
env:
OS: ${{ matrix.OS }}
OS_VARIANT: ${{ matrix.OS_VARIANT }}
ANSIBLE_VERSION: ${{ matrix.ANSIBLE_VERSION }}
TAG_OS: ${{ matrix.TAG_OS }}
TAG_LATEST: ${{ matrix.TAG_LATEST }}
BASE_REGISTRY_NAMESPACE: library
BASE_IMAGE_NAME: ${{ matrix.OS }}
BASE_TAG_FULL: ${{ matrix.BASE_IMAGE_TAG }}
BUILD_REGISTRY_NAMESPACE: ${{ vars.DOCKERHUB_REGISTRY_USER }}
BUILD_IMAGE_NAME: ansible
BUILD_TAG_FULL: ${{ matrix.ANSIBLE_VERSION }}-${{ matrix.OS }}-${{ matrix.OS_VARIANT }}${{ matrix.SUFFIX_PPA }}
BUILD_CONTEXT: variants/${{ matrix.OS }}/${{ matrix.OS_VARIANT }}${{ matrix.SUFFIX_PPA }}
steps:
- uses: actions/checkout@v3
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
docker info
docker version
- name: Login to docker registry
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
env:
DOCKERHUB_REGISTRY_USER: ${{ vars.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
- name: Build image
run: |
set -e
echo "OS: $OS"
echo "OS_VARIANT: $OS_VARIANT"
echo "ANSIBLE_VERSION: $ANSIBLE_VERSION"
echo "TAG_OS: $TAG_OS"
echo "TAG_LATEST: $TAG_LATEST"
echo "BASE_REGISTRY_NAMESPACE: $BASE_REGISTRY_NAMESPACE"
echo "BASE_IMAGE_NAME: $BASE_IMAGE_NAME"
echo "BASE_TAG_FULL: $BASE_TAG_FULL"
echo "BUILD_REGISTRY_NAMESPACE: $BUILD_REGISTRY_NAMESPACE"
echo "BUILD_IMAGE_NAME: $BUILD_IMAGE_NAME"
echo "BUILD_TAG_FULL: $BUILD_TAG_FULL"
echo "BUILD_CONTEXT: $BUILD_CONTEXT"
echo "BASE_IMAGE: ${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL}"
echo "BUILD_IMAGE: ${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}"
time docker pull "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" || true
time docker build \
--cache-from "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" \
-t "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" \
--build-arg BASE_IMAGE="${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL}" \
"$BUILD_CONTEXT"
if [ "${TAG_OS}" = 'true' ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${OS}"
fi
if [ "${TAG_LATEST}" = 'true' ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:latest"
fi
docker images
docker inspect "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}"
- name: Test image
run: docker run -t --rm "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}" ansible --version
- name: Push image
if: startsWith(github.ref, 'refs/tags/')
run: docker push -a "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}"
- name: Clean-up
run: docker logout
if: always()
update-draft-release:
needs: [alpine, ubuntu]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-draft-release:
needs: [alpine, ubuntu]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: true
name: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3'
tag: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dockerhub-description:
needs: [alpine, ubuntu]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: peter-evans/dockerhub-description@v3
with:
username: ${{ vars.DOCKERHUB_REGISTRY_USER }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
repository: ${{ vars.DOCKERHUB_REGISTRY_USER }}/ansible
short-description: ${{ github.event.repository.description }}
readme-filepath: README.md