commento/.gitlab-ci.yml

127 lines
3.0 KiB
YAML
Raw Normal View History

2018-06-07 17:16:51 +08:00
stages:
2018-08-13 02:40:33 +08:00
- check-dco
2018-06-17 20:18:35 +08:00
- go-fmt
- go-test
2018-06-07 17:16:51 +08:00
- build-src
- aws-upload-tags
2018-06-07 17:16:51 +08:00
- build-docker
- docker-registry-master
- docker-registry-tags
2018-06-07 17:16:51 +08:00
2018-08-13 02:40:33 +08:00
check-dco:
stage: check-dco
image: debian:buster
except:
- master
- tags
2018-08-13 02:40:33 +08:00
script:
- apt update
- apt install -y curl git jq
- bash ./scripts/check-dco
2018-06-07 17:16:51 +08:00
build-src:
stage: build-src
image: debian:buster
except:
- master
- tags
2018-10-18 13:18:01 +08:00
before_script:
- bash $CI_PROJECT_DIR/scripts/gitlab-ci-build-prescript
script:
2018-10-18 13:18:01 +08:00
- export GOPATH=/go
- export PATH=$PATH:/go/bin
- cd /go/src/$CI_PROJECT_NAME
2018-06-07 17:16:51 +08:00
- make devel
- make prod
aws-upload-tags:
stage: aws-upload-tags
image: debian:buster
environment: aws-upload-tags
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
only:
- 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 prod
- cd build/prod && tar -zcvf /commento-linux-amd64-$(git describe --tags).tar.gz .
- aws s3 cp /commento-linux-amd64-$(git describe --tags).tar.gz s3://commento-release/
2018-06-07 17:16:51 +08:00
build-docker:
stage: build-docker
image: docker:stable
services:
- docker:dind
except:
- master
- tags
2018-06-07 17:16:51 +08:00
script:
- docker build -t commento .
2018-06-07 17:16:51 +08:00
go-test:
stage: go-test
2019-06-06 16:56:28 +08:00
image: golang:1.12
2018-06-07 17:16:51 +08:00
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
2018-10-18 13:18:01 +08:00
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
2018-06-07 17:16:51 +08:00
script:
2018-10-18 13:18:01 +08:00
- cd /go/src/$CI_PROJECT_NAME
- make test
2018-06-17 20:18:35 +08:00
go-fmt:
stage: go-fmt
image: golang:1.10.2
except:
- master
- tags
2018-06-17 20:18:35 +08:00
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)