forked from MarijnKoesen/prometheus-aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
51 lines (46 loc) · 1.05 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
45
46
47
48
49
50
51
stages:
- test
- build
variables:
MODCACHEDIR: $CI_PROJECT_DIR/.gomod
VERSION: v0.0.5
.prep-go-env: &prep-go-env
before_script:
- mkdir -p $MODCACHEDIR $GOPATH/pkg
- ln -s $MODCACHEDIR $GOPATH/pkg/mod
test:
stage: test
image: $CI_REGISTRY/sre/gudang/golang:2.1.0
<<: *prep-go-env
script:
- go test -v
cache:
key: gomod
paths:
- $MODCACHEDIR
compile:
image: $CI_REGISTRY/sre/gudang/golang:2.1.0
stage: test
script:
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o deploy/_output/prometheus-aggregator -mod=readonly -ldflags="-s -w"
cache:
key: gomod
paths:
- $MODCACHEDIR
artifacts:
expire_in: 1 days
paths:
- deploy/_output
build-image:
stage: build
image: $CI_REGISTRY/sre/gudang/docker:1.0.0
when: manual
tags:
- bare-metal
dependencies:
- compile
script:
- TAG=$CI_REGISTRY/bukalapak/prometheus-aggregator:$VERSION
- docker login -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --no-cache -t $TAG .
- docker push $TAG