-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
89 lines (84 loc) · 2.88 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
stages:
- pages
- docker:build
- docker:deploy
- sync
variables:
DOCKER_TAG: 1.0.0
pages:
stage: pages
image: registry.cn-qingdao.aliyuncs.com/xuxiaoweicomcn/node:20.12.0
cache:
key: "${CI_JOB_NAME}"
paths:
- node_modules/
script:
- npm run pre:npm
- if [ $CI_SERVER_HOST == 'framagit.org' ]; then
cat .vitepress/config.mts;
sed -i 's#在 Gitee 上编辑此页面#在 FramaGit 上编辑#g' .vitepress/config.mts;
sed -i 's#https://gitee.com/xuxiaowei-com-cn/gitlab-k8s/edit/main/#https://framagit.org/xuxiaowei-com-cn/gitlab-k8s/-/edit/main/#g' .vitepress/config.mts;
cat .vitepress/config.mts;
fi
- npm run docs:build
- cp -r .vitepress/dist/* public/
artifacts:
expire_in: 1 week
paths:
- public/
rules:
- if: $CI_COMMIT_BRANCH == "main" && $ENABLE_DOCS == "true"
docker:build:
stage: docker:build
image:
name: registry.cn-qingdao.aliyuncs.com/xuxiaoweicomcn/kaniko-project-executor:v1.23.1-debug
entrypoint: [ "" ]
needs:
- job: pages
artifacts: true
before_script:
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"https://index.docker.io/v1/\":{\"auth\":\"$(printf "%s:%s" ${DOCKER_USERNAME} "${DOCKER_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- echo $DOCKER_TAG
- /kaniko/executor version
- /kaniko/executor --help
- if [ "$PUSH_DOCKER_HUB" = "true" ]; then
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--build-arg "CI_PIPELINE_URL=${CI_PIPELINE_URL}"
--destination "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}"
--destination "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}-${CI_PIPELINE_ID}"
--destination "xuxiaoweicomcn/gitlab-k8s:${DOCKER_TAG}"
--destination "xuxiaoweicomcn/gitlab-k8s:${DOCKER_TAG}-${CI_PIPELINE_ID}";
else
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--build-arg "CI_PIPELINE_URL=${CI_PIPELINE_URL}"
--destination "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}"
--destination "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}-${CI_PIPELINE_ID}";
fi
rules:
- if: $CI_COMMIT_BRANCH == "main" && $ENABLE_DOCS_DOCKER == "true"
docker:deploy:
stage: docker:deploy
needs:
- job: docker:build
image: registry.cn-qingdao.aliyuncs.com/xuxiaoweicomcn/docker:26.1.3-cli
variables:
DOCKER_HOST: $DEPLOY_DOCKER_HOST
script:
- docker info
- docker compose up -d
- docker images | grep gitlab-k8s
- docker images | grep gitlab-k8s | awk '{print $3}' | xargs docker rmi || echo
environment: production
rules:
- if: $CI_COMMIT_BRANCH == "main" && $ENABLE_DOCS_DOCKER_DEPLOY == "true"
tags:
- lighthouse-docker
# 嵌入
include:
# 同步代码
- /sync.yml