.gitlab-ci.yml: auto-build docker image on tags

This commit is contained in:
Adhityaa Chandrasekar 2018-09-26 03:52:16 -04:00
parent c5d2e17615
commit 0d6dfb8319

View File

@ -4,13 +4,15 @@ stages:
- go-test - go-test
- build-src - build-src
- build-docker - build-docker
- docker-registry - docker-registry-master
- docker-registry-tags
check-dco: check-dco:
stage: check-dco stage: check-dco
image: debian:buster image: debian:buster
except: except:
- master - master
- tags
script: script:
- apt update - apt update
- apt install -y curl git jq - apt install -y curl git jq
@ -23,6 +25,7 @@ build-src:
GOPATH: $CI_PROJECT_DIR GOPATH: $CI_PROJECT_DIR
except: except:
- master - master
- tags
script: script:
- apt update - apt update
- apt install -y curl gnupg git make golang - apt install -y curl gnupg git make golang
@ -41,6 +44,7 @@ build-docker:
- docker:dind - docker:dind
except: except:
- master - master
- tags
script: script:
- docker build -t commento-ce . - docker build -t commento-ce .
@ -57,6 +61,7 @@ go-test:
GOPATH: $CI_PROJECT_DIR GOPATH: $CI_PROJECT_DIR
except: except:
- master - master
- tags
script: script:
- mkdir -p src/gitlab.com/commento && cd src/gitlab.com/commento && ln -s $CI_PROJECT_DIR && cd $CI_PROJECT_NAME - mkdir -p src/gitlab.com/commento && cd src/gitlab.com/commento && ln -s $CI_PROJECT_DIR && cd $CI_PROJECT_NAME
- make test - make test
@ -66,12 +71,13 @@ go-fmt:
image: golang:1.10.2 image: golang:1.10.2
except: except:
- master - master
- tags
script: script:
- cd api - cd api
- test -z $(go fmt) - test -z $(go fmt)
docker-registry: docker-registry-master:
stage: docker-registry stage: docker-registry-master
image: docker:stable image: docker:stable
services: services:
- docker:dind - docker:dind
@ -83,3 +89,16 @@ docker-registry:
- docker pull registry.gitlab.com/commento/commento-ce:latest || true - 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 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 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)