-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
53 lines (46 loc) · 1.32 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
52
53
---
image: golang:latest
variables:
# Please edit to your GitLab project
REPO_NAME: github.com/kofemann/autoca
stages:
- test
- build
- containerize
format:
image: golang:latest
stage: test
before_script:
- cd $GOPATH/src
- mkdir -p $REPO_NAME
- rmdir $REPO_NAME
- ln -svf $CI_PROJECT_DIR $REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- go mod init
- go get gopkg.in/yaml.v2
script:
- go fmt $(go list ./...)
- go test -race $(go list ./...)
compile:
image: golang:latest
stage: build
before_script:
- cd $GOPATH/src
- mkdir -p $REPO_NAME
- rmdir $REPO_NAME
- ln -svf $CI_PROJECT_DIR $REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- go mod init
- go get gopkg.in/yaml.v2
script:
- go build -race -ldflags "-extldflags '-static' -X main.revision=`git describe --always --long --dirty`" -o $CI_PROJECT_DIR/autoca
artifacts:
paths:
- autoca
containerize:
stage: containerize
image: gcr.io/kaniko-project/executor:debug
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG