-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
108 lines (99 loc) · 2.69 KB
/
.gitlab-ci.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
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- deploy
variables:
fedora_ansible_image_name: "fedora-ansible"
docker_namespace: "remyj38"
tags_files: "tags"
before_script:
- docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- "[[ -d $tags_files ]] || mkdir $tags_files"
build-28:
artifacts:
expire_in: 1 day
paths:
- image-*.tar
- $tags_files/
only:
- fedora-ansible
script:
- docker build --pull fedora-28/ | tee output.log
- image_id=`cat output.log | tail -n1 | awk '{print $(NF)}'`
- echo "$CI_REGISTRY_IMAGE/$fedora_ansible_image_name:latest" > "$tags_files/$image_id"
- echo "$CI_REGISTRY_IMAGE/$fedora_ansible_image_name:28" >> "$tags_files/$image_id"
- echo "$docker_namespace/$fedora_ansible_image_name:latest" >> "$tags_files/$image_id"
- echo "$docker_namespace/$fedora_ansible_image_name:28" >> "$tags_files/$image_id"
- docker save -o "image-$image_id.tar" "$image_id"
stage: build
build-rawhide:
artifacts:
expire_in: 1 day
paths:
- image-*.tar
- $tags_files/
only:
- fedora-ansible
stage: build
script:
- docker build --pull fedora-rawhide/ | tee output.log
- image_id=`cat output.log | tail -n1 | awk '{print $(NF)}'`
- echo "$CI_REGISTRY_IMAGE/$fedora_ansible_image_name:rawhide" > "$tags_files/$image_id"
- echo "$docker_namespace/$fedora_ansible_image_name:rawhide" >> "$tags_files/$image_id"
- docker save -o "image-$image_id.tar" "$image_id"
test:
artifacts:
expire_in: 1 day
paths:
- image-*.tar
- $tags_files/
dependencies:
- build-28
- build-rawhide
only:
- fedora-ansible
script:
- cd $tags_files
# Load images
- for image_id in *; do
echo "Loading $image_id";
docker load -q -i "../image-$image_id.tar";
done
# Show ansible version
- for image_id in *; do
echo "Ansible version of $image_id";
docker run "$image_id" ansible --version;
done
stage: test
when: on_success
deploy:
dependencies:
- test
only:
- fedora-ansible
script:
- cd $tags_files
# Load images
- for image_id in *; do
echo "Loading $image_id";
docker load -q -i "../image-$image_id.tar";
done
# Tag images
- for image_id in *; do
while read tag; do
docker tag "$image_id" "$tag";
done <"$image_id";
done
# Push images
- for image_id in *; do
while read tag; do
echo "Pushing $tag";
docker push "$tag";
done <$image_id;
done
stage: deploy
when: on_success