-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
95 lines (85 loc) · 1.97 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
image: golang:1.13.5
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
cache:
paths:
- .go/pkg/mod/
stages:
- test
- build
- build-docker
- integration-test
- deploy
pages:
stage: deploy
script:
- mkdir public
- cp -r docs/. public
artifacts:
paths:
- public
only:
- master
test:
tags:
- shell-clamp
stage: test
script:
- go test clamp-core/executors clamp-core/models clamp-core/services
only:
- merge_requests
- master
build:
tags:
- shell-clamp
stage: build
script:
- go build
artifacts:
paths:
- ./clamp-core
only:
- master
build-docker:
tags:
- shell-clamp
stage: build-docker
before_script:
- docker info
script:
- docker build -t registry.gitlab.com/sahajsoft/clamp/clamp-core:$CI_COMMIT_SHA .
- docker login registry.gitlab.com -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker push registry.gitlab.com/sahajsoft/clamp/clamp-core
- docker system prune -f -a
only:
- ci-cd
- master
deploy:
tags:
- shell-clamp
stage: deploy
dependencies:
- build-docker
script:
- rm -rf /home/ubuntu/clamp/*
- docker login registry.gitlab.com -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker container stop clamp || docker container rm clamp || true
- docker system prune -f -a
- docker pull registry.gitlab.com/sahajsoft/clamp/clamp-core:$CI_COMMIT_SHA
- docker run --name=clamp -d --restart always -p0.0.0.0:8642:8080 registry.gitlab.com/sahajsoft/clamp/clamp-core:$CI_COMMIT_SHA
- docker tag registry.gitlab.com/sahajsoft/clamp/clamp-core:$CI_COMMIT_SHA registry.gitlab.com/sahajsoft/clamp/clamp-core:demo-$CI_COMMIT_SHA
- docker push registry.gitlab.com/sahajsoft/clamp/clamp-core:demo-$CI_COMMIT_SHA
only:
- ci-cd
- master
integration-test:
tags:
- shell-clamp
stage: integration-test
script:
- go test clamp-core/handlers
only:
- master