-
Notifications
You must be signed in to change notification settings - Fork 90
/
.gitlab-ci.yml
60 lines (53 loc) · 1.43 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
default:
image: docker:latest
stages:
- test
- build
- deploy
variables:
IMAGE_NAME: "csghub-server"
IMAGE_TAG: "latest"
SAST_IMAGE_SUFFIX: '-fips'
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
include:
- template: Jobs/Secret-Detection.gitlab-ci.yml
test:
stage: test
image: golang:1.21.0
script:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go build -o starhub ./cmd/csghub-server
except:
- main
build_server_image:commit:
image: docker:24.0.6
stage: build
services:
- docker:24.0.6-dind
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
LATEST_IMAGE_TAG: "$CI_REGISTRY_IMAGE:latest"
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE_TAG -f docker/Dockerfile .
- docker tag $IMAGE_TAG $LATEST_IMAGE_TAG
- docker push $IMAGE_TAG
- docker push $LATEST_IMAGE_TAG
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH == $CI_COMMIT_REF_NAME # when commit to main branch
build_server_image:tag:
image: docker:24.0.6
stage: build
services:
- docker:24.0.6-dind
only:
refs:
- tags
variables:
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE_TAG -f docker/Dockerfile .
- docker push $IMAGE_TAG