forked from CityOfZion/neo-scan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
82 lines (75 loc) · 2.18 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
stages:
- test
- build
- deploy
variables:
POSTGRES_DB: neoscan_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "postgres"
before_script:
- export IMAGE_TAG="$CI_PIPELINE_ID-$CI_COMMIT_REF_SLUG"
- export REGISTRY_PATH="$CI_REGISTRY_IMAGE:$IMAGE_TAG"
- export HAPROXY_REGISTRY_PATH="$CI_REGISTRY_IMAGE/haproxy:$IMAGE_TAG"
test:
stage: test
image: bitwalker/alpine-elixir-phoenix:1.6.5
services:
- postgres
cache:
key: build-cache
paths:
- deps/
- _build/
script:
- mix local.rebar --force
- mix local.hex --force
- mix deps.get
- mix format --check-formatted
- mix coveralls.post -u --token "${COVERALLS_REPO_TOKEN}" --branch "${CI_COMMIT_REF_NAME}" --message "${CI_COMMIT_TITLE}" --sha "${CI_COMMIT_SHA}" --service_name "gitlab"
- rm -Rf _build/test/lib/neo*
neoscan-build:
stage: build
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build -t $REGISTRY_PATH .
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker push $REGISTRY_PATH
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $REGISTRY_PATH $CI_REGISTRY_IMAGE || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE || true"
haproxy-build:
stage: build
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- cd haproxy && docker build -t $HAPROXY_REGISTRY_PATH .
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker push $HAPROXY_REGISTRY_PATH
staging:
stage: deploy
environment: staging
script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker-compose -f docker-compose.prod.yml up -d
variables:
HOST: neoscan.backslash.fr
tags:
- staging
when: manual
production:
stage: deploy
environment: production
script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker-compose -f docker-compose.prod.yml up -d
variables:
HOST: api.neoscan.io
tags:
- production
when: manual
only:
- master