forked from erlang/docker-erlang-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
49 lines (45 loc) · 1.25 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
stages:
- build
- test
- container
before_script:
- apk update
- apk --no-cache upgrade
- apk --no-cache add git
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/".insteadOf 'git@gitlab.com:'
build:
stage: build
image: erlang:alpine
artifacts:
untracked: true
paths:
- _build
script:
# Prepare environmental variables
- wget https://s3.amazonaws.com/rebar3/rebar3 && chmod a+x rebar3
- ./rebar3 compile
check:
stage: test
image: erlang:alpine
dependencies:
- build
artifacts:
when: always
untracked: true
paths:
- _build
script:
- ./rebar3 do xref, ct
docker:
image: docker:git
stage: container
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -f Dockerfile .
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- if [ $CI_COMMIT_REF_NAME == "master" ] ; then docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest ; docker push $CI_REGISTRY_IMAGE:latest ; fi
when: always