-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
174 lines (148 loc) · 4.57 KB
/
.gitlab-ci.yml
File metadata and controls
174 lines (148 loc) · 4.57 KB
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
stages:
- build
- test
- release
variables:
DOCKER_HUB_REPO: ccoley/ansible
.build:
stage: build
tags: [docker]
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- >-
/kaniko/executor
--cache=false
--skip-unused-stages
--target "$BUILD_TARGET"
--context "$CI_PROJECT_DIR"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-${ANSIBLE_VERSION}"
--label org.opencontainers.image.authors="$LABEL_AUTHORS"
--label org.opencontainers.image.created="$(date -u -Iseconds)"
--label org.opencontainers.image.revision="$CI_COMMIT_SHA"
--label org.opencontainers.image.source="$CI_PROJECT_URL"
--build-arg ALPINE_VERSION="$ALPINE_VERSION"
--build-arg ANSIBLE_VERSION="$ANSIBLE_VERSION"
build:latest:
extends: .build
variables:
ALPINE_VERSION: 3.23
ANSIBLE_VERSION: '2.20'
BUILD_TARGET: default
build:python3.8:
extends: .build
variables:
ALPINE_VERSION: 3.22
ANSIBLE_VERSION: 2.18
BUILD_TARGET: default
build:python2.7:
extends: .build
variables:
ALPINE_VERSION: 3.19
ANSIBLE_VERSION: 2.16
BUILD_TARGET: default
build:2.10:
extends: .build
when: manual
variables:
ALPINE_VERSION: 3.14
ANSIBLE_VERSION: '2.10'
BUILD_TARGET: ansible-classic
build:2.9:
extends: .build
when: manual
variables:
ALPINE_VERSION: 3.12
ANSIBLE_VERSION: 2.9
BUILD_TARGET: ansible-classic
.test:
stage: test
tags: [docker]
image:
name: "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-${ANSIBLE_VERSION}"
pull_policy: always
script:
- ansible --version
- ansible --version | grep -Eq "ansible( \[core)? $ANSIBLE_VERSION"
test:latest:
extends: .test
needs: ['build:latest']
variables:
ANSIBLE_VERSION: '2.20'
test:python3.8:
extends: .test
needs: ['build:python3.8']
variables:
ANSIBLE_VERSION: 2.18
test:python2.7:
extends: .test
needs: ['build:python2.7']
variables:
ANSIBLE_VERSION: 2.16
test:2.10:
extends: .test
needs: ['build:2.10']
variables:
ANSIBLE_VERSION: '2.10'
test:2.9:
extends: .test
needs: ['build:2.9']
variables:
ANSIBLE_VERSION: 2.9
.release:
stage: release
tags: [docker]
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: ['']
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
- crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- crane auth login -u "$DOCKER_HUB_USERNAME" -p "$DOCKER_HUB_TOKEN" index.docker.io
release:latest:
extends: .release
needs: ['test:latest']
script:
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.20 2.20
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.20 python3.9
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.20 latest
- crane copy ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.20 ${DOCKER_HUB_REPO}:2.20
- crane tag ${DOCKER_HUB_REPO}:2.20 python3.9
- crane tag ${DOCKER_HUB_REPO}:2.20 latest
release:python3.8:
extends: .release
needs: ['test:python3.8']
script:
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.18 2.18
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.18 python3.8
- crane copy ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.18 ${DOCKER_HUB_REPO}:2.18
- crane tag ${DOCKER_HUB_REPO}:2.18 python3.8
release:python2.7:
extends: .release
needs: ['test:python2.7']
script:
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.16 2.16
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.16 python2.7
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.16 python3.6
- crane copy ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.16 ${DOCKER_HUB_REPO}:2.16
- crane tag ${DOCKER_HUB_REPO}:2.16 python2.7
- crane tag ${DOCKER_HUB_REPO}:2.16 python3.6
release:2.10:
extends: .release
needs: ['test:2.10']
script:
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.10 2.10
- crane copy ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.10 ${DOCKER_HUB_REPO}:2.10
release:2.9:
extends: .release
needs: ['test:2.9']
script:
- crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.9 2.9
- crane copy ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-2.9 ${DOCKER_HUB_REPO}:2.9
# vi: set ts=2 sw=2 et ft=yaml: