-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
54 lines (49 loc) · 1.52 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
stages:
- build
- deploy
build-image-dev:
stage: build
tags: [ ikey-shell ]
only:
- develop
script:
- GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/main main.go
- docker buildx build -f Dockerfile.slim -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:dev --push .
build-image-prod:
stage: build
tags: [ ikey-shell ]
only:
- tags
script:
- GIT_TERMINAL_PROMPT=1 GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/main main.go
- docker buildx build -f Dockerfile.slim -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${CI_COMMIT_TAG} --push .
deploy-to-dev:
stage: deploy
tags: [ ikey-shell ]
only:
- develop
dependencies:
- build-image-dev
before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "GitLab CI/CD"
script:
- git clone -b main ${GIT_SSH_REPO}
- cd argocd && sed -i "s/gitTag:.*/gitTag:\ '$CI_COMMIT_SHORT_SHA'/g" $PROJECT/dev-values.yaml
- git commit -am "update image tag to $CI_COMMIT_SHORT_SHA"
- git push origin main
deploy-to-prod:
stage: deploy
tags: [ ikey-shell ]
only:
- tags
dependencies:
- build-image-prod
before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "GitLab CI/CD"
script:
- git clone -b main ${GIT_SSH_REPO}
- cd argocd && sed -i "s/tag:.*/tag:\ '$CI_COMMIT_TAG'/g" $PROJECT/prod-values.yaml
- git commit -am "update image tag to $CI_COMMIT_TAG"
- git push origin main