forked from adtac/commento
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
93 lines (87 loc) · 2.12 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
stages:
- go-fmt
- go-test
- build-src
- build-docker
- docker-registry-master
- docker-registry-tags
build-src:
stage: build-src
image: debian:buster
except:
- master
- tags
before_script:
- bash $CI_PROJECT_DIR/scripts/gitlab-ci-build-prescript
script:
- export GOPATH=/go
- export PATH=$PATH:/go/bin
- cd /go/src/$CI_PROJECT_NAME
- make devel
- make prod
build-docker:
stage: build-docker
image: docker:stable
services:
- docker:dind
except:
- master
- tags
script:
- docker build -t commento .
go-test:
stage: go-test
image: golang:1.14
services:
- postgres:9.6
variables:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: commento_test
COMMENTO_POSTGRES: postgres://postgres:postgres@postgres/commento_test?sslmode=disable
except:
- master
- tags
before_script:
- mkdir -p /go/src /go/bin /go/pkg
- export GOPATH=/go
- export PATH=$PATH:/go/bin
- ln -s $CI_PROJECT_DIR /go/src/$CI_PROJECT_NAME
script:
- cd /go/src/$CI_PROJECT_NAME
- make test
go-fmt:
stage: go-fmt
image: golang:1.14
except:
- master
- tags
script:
- cd api
- test -z $(go fmt)
docker-registry-master:
stage: docker-registry-master
image: docker:stable
services:
- docker:dind
only:
- master@commento/commento
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- docker pull registry.gitlab.com/commento/commento:latest || true
- docker build --cache-from registry.gitlab.com/commento/commento:latest --tag registry.gitlab.com/commento/commento:latest .
- docker push registry.gitlab.com/commento/commento:latest
docker-registry-tags:
stage: docker-registry-tags
image: docker:stable
services:
- docker:dind
only:
- tags
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- apk add git
- docker build --tag registry.gitlab.com/commento/commento:$(git describe --tags) .
- docker push registry.gitlab.com/commento/commento:$(git describe --tags)