-
Notifications
You must be signed in to change notification settings - Fork 20
/
.gitlab-ci.yml
45 lines (40 loc) · 1.01 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
image: golang:1
stages:
- build
- image
variables:
DOCKER_DRIVER: overlay2
compile:
stage: build
script:
- go version
- go mod download
- if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi;
- go vet
- go test
- CGO_ENABLED=0 go build -o yarn-prometheus-exporter .
artifacts:
name: "artifact_{$CI_COMMIT_SHA}"
expire_in: 30 min
paths:
- yarn-prometheus-exporter
- Dockerfile
build-docker:
stage: image
image: docker:latest
services:
- docker:dind
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- if [ "${CI_COMMIT_REF_SLUG}" == "master" ]; then IMAGE_TAG="latest"; else IMAGE_TAG="${CI_COMMIT_REF_SLUG}"; fi
- docker build --pull -t $CI_REGISTRY_IMAGE:$IMAGE_TAG .
- docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG
dependencies:
- compile
variables:
GIT_STRATEGY: none
tags:
- docker-images