Untitled
# 打包镜像并修改镜像tag
variables:
IMAGE_NAME: "docker.cnb.cool/zzppjj/docker-images/litghtpicture"
IMAGE_TAG: "$CI_COMMIT_SHORT_SHA"
CONFIG_REPO: "git@192.168.51.50:root/argo-demo.git"
stages:
- build
- deploy
build:
stage: build
image: docker:24.0
services:
- docker.cnb.cool/zzppjj/docker-images/docker:24.0-dind
script:
- docker login -u cnb docker.cnb.cool -p 01d21Lwxp6gMZBcf0o7BnPeaNgM
- docker build -t $IMAGE_NAME:$IMAGE_TAG -t $IMAGE_NAME:latest .
- docker push $IMAGE_NAME:$IMAGE_TAG
- docker push $IMAGE_NAME:latest
only:
- main
update-manifests:
stage: deploy
image: docker.cnb.cool/zzppjj/docker-images/git # 留着没事,等以后换了 Docker Executor 会自动生效
needs: ["build"]
script:
# 1. 删掉了 apk add --no-cache git openssh-client (因为宿主机已经装好了)
- git config --global user.email "ci@gitlab.com"
- git config --global user.name "GitLab CI"
- git clone $CONFIG_REPO
- cd argo-demo
- cd manifests
- |
find . -type f \( -name "*.yaml" -o -name "*.yml" \) | xargs sed -i "s|image: .*picture:[^[:space:]]*|image: $IMAGE_NAME:$IMAGE_TAG|g"
- git add .
- |
git diff --cached --quiet || git commit -m "chore: update image $IMAGE_NAME to $IMAGE_TAG [skip ci]"
- git push origin main
only:
- main
environment: production
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
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
上次更新: 2026/06/04, 16:55:11
|