commento/.gitlab-ci.yml
2018-09-26 04:01:10 -04:00

105 lines
2.5 KiB
YAML

stages:
- check-dco
- go-fmt
- go-test
- build-src
- build-docker
- docker-registry-master
- docker-registry-tags
check-dco:
stage: check-dco
image: debian:buster
except:
- master
- tags
script:
- apt update
- apt install -y curl git jq
- bash ./scripts/check-dco
build-src:
stage: build-src
image: debian:buster
variables:
GOPATH: $CI_PROJECT_DIR
except:
- master
- tags
script:
- apt update
- apt install -y curl gnupg git make golang
- curl -sL https://deb.nodesource.com/setup_10.x | bash -
- apt update
- apt install -y nodejs
- npm install -g html-minifier@3.5.7 uglify-js@3.4.1 sass@1.5.1
- mkdir -p src/gitlab.com/commento && cd src/gitlab.com/commento && ln -s $CI_PROJECT_DIR && cd $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-ce .
go-test:
stage: go-test
image: golang:1.10.2
services:
- postgres:latest
variables:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: commento_test
COMMENTO_POSTGRES: postgres://postgres:postgres@postgres/commento_test?sslmode=disable
GOPATH: $CI_PROJECT_DIR
except:
- master
- tags
script:
- mkdir -p src/gitlab.com/commento && cd src/gitlab.com/commento && ln -s $CI_PROJECT_DIR && cd $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-ce
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- docker pull registry.gitlab.com/commento/commento-ce:latest || true
- docker build --cache-from registry.gitlab.com/commento/commento-ce:latest --tag registry.gitlab.com/commento/commento-ce:latest .
- docker push registry.gitlab.com/commento/commento-ce: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:
- docker build --tag registry.gitlab.com/commento/commento-ce:$(git describe --tags) .
- docker push registry.gitlab.com/commento/commento-ce:$(git describe --tags)