-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
67 lines (67 loc) · 1.66 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
stages:
- test
- build
- package
- deploy
test:
image: yeyudekuangxiang/go-test:latest
stage: test
tags:
- test
variables:
TEST_ENV: real
GO111MODULE: on
GOPROXY: https://goproxy.cn,https://goproxy.io,direct
CGO_ENABLED: 0
before_script:
- cat config.ini.example | sed "2c TokenKey=${TokenKey}" >> config.ini
- /etc/init.d/mysql start
- service mysql status
- mysql -uroot -proot -e "grant all on *.* to root@'%' identified by 'root';flush privileges;"
- mysql --user=root --password=root -e "CREATE DATABASE gink charset=utf8mb4;"
- mysql -uroot -proot gink < ./mock/sql/gink.sql
script:
- go mod download
- cd tests
- go test ./... -v
build:
image: golang:1.14
stage: build
only:
- develop
- tags
tags:
- docker
script:
- env GOPROXY=https://goproxy.cn,https://goproxy.io,direct CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build .
artifacts:
paths:
- gink
package:
stage: package
only:
- develop
- tags
tags:
- shell
dependencies:
- build
script:
- docker build -t registry.cn-hangzhou.aliyuncs.com/branch/gink:$CI_COMMIT_REF_NAME -f ./build/Dockerfile .
- docker login --username=$DOCKER_USER --password=$DOCKER_PWD registry.cn-hangzhou.aliyuncs.com
- docker push registry.cn-hangzhou.aliyuncs.com/branch/gink:$CI_COMMIT_REF_NAME
deploy:
image:
name: bitnami/kubectl:1.20.10
entrypoint: [""]
stage: deploy
only:
- develop
- tags
tags:
- docker
before_script:
- echo ${k8s_config} | base64 -d >> ./config-ali
- export KUBECONFIG=$(pwd)/config-ali
script:
- bash ./build/deploy.sh $CI_COMMIT_REF_NAME