95 lines
2.2 KiB
YAML
95 lines
2.2 KiB
YAML
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.12
|
|
services:
|
|
- postgres:latest
|
|
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
|
|
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
- 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.10.2
|
|
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)
|