-
Notifications
You must be signed in to change notification settings - Fork 10
/
.gitlab-ci.yml
79 lines (75 loc) · 2.68 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
stages:
- setup-local-machine
- build-docker-image
- build-catkin-workspace
- deploy-docker-image
setup-local-machine:
image: ubuntu:xenial
stage: setup-local-machine
before_script:
# Install tools missing in ubuntu:xenial.
- apt-get update
- apt-get install -y sudo
- apt-get install -y openssh-client
script:
- sh ./SETUP-MACHINE.sh
build-docker-image:
image: docker:latest
services:
# Use Docker-in-Docker (begin).
# https://gitlab.com/help/ci/docker/using_docker_build.md#use-docker-in-docker-executor
- docker:dind
stage: build-docker-image
before_script:
# Upgrade packages.
- apk update
- apk upgrade
# Install Docker Compose.
- apk add py-pip
- pip install docker-compose
# Login to GitLab Container Registry.
# https://gitlab.com/help/ci/docker/using_docker_build.md#using-the-gitlab-container-registry
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- sh ./BUILD-IMAGE.sh
after_script:
# Push image to GitLab Container Registry.
# https://gitlab.com/help/ci/docker/using_docker_build.md#using-the-gitlab-container-registry
- docker tag docker_ur:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
build-catkin-workspace:
image: docker:latest
services:
# Use Docker-in-Docker (begin).
# https://gitlab.com/help/ci/docker/using_docker_build.md#use-docker-in-docker-executor
- docker:dind
stage: build-catkin-workspace
before_script:
# Login to GitLab Container Registry.
# https://gitlab.com/help/ci/docker/using_docker_build.md#using-the-gitlab-container-registry
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker run
-e CI_REPOSITORY_URL=$CI_REPOSITORY_URL
-e CI_PROJECT_NAME=$CI_PROJECT_NAME
-e CI_COMMIT_SHA=$CI_COMMIT_SHA
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME /root/scripts/gitlab-ci/build-catkin-workspace.sh
deploy-docker-image:
only:
- master
- devel
image: docker:latest
services:
# Use Docker-in-Docker (begin).
# https://gitlab.com/help/ci/docker/using_docker_build.md#use-docker-in-docker-executor
- docker:dind
stage: deploy-docker-image
before_script:
# Login to GitLab Container Registry.
# https://gitlab.com/help/ci/docker/using_docker_build.md#using-the-gitlab-container-registry
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest