-
Notifications
You must be signed in to change notification settings - Fork 85
/
.gitlab-ci.yml
72 lines (68 loc) · 2.29 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
image: registry.cn-beijing.aliyuncs.com/authing-next/authing-server:ci-base
stages:
- build
before_script:
- git config http.postBuffer 2097152000
- mkdir -p ~/.ssh
- touch ~/.ssh/id_rsa
- touch ~/.ssh/config
- chmod 700 ~/.ssh/id_rsa
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- echo "$SSH_CONFIG" > ~/.ssh/config
- export VERSION=$(cat version.txt)
- VERSION_TAG=${VERSION}
- |
case "$CI_COMMIT_REF_NAME" in
"master")
export VERSION=$(cat version.txt)
OSS_REGION=${OSS_REGION_PROD}
OSS_URL=${CDN_OSS_PROD}
PUBLIC_URL=//cdn.authing.co/authing-docs-v2/${VERSION}/
;;
*)
export VERSION=$(cat version.txt)-${CI_COMMIT_SHORT_SHA}
OSS_REGION=${OSS_REGION_DAILY}
OSS_URL=${CDN_OSS_DAILY}
PUBLIC_URL=//cdn-daily.authing.co/authing-docs-v2/${VERSION}/
;;
esac
# yarn 构建文档并 git 打 tag
build:
cache:
key: node_deps
paths:
- node_modules
stage: build
rules:
- when: manual
script:
- yarn --registry https://registry.npm.taobao.org
- NODE_OPTIONS=--max_old_space_size=8192 PUBLIC_URL=$PUBLIC_URL yarn docs:build
- echo $CI_COMMIT_REF_NAME
- docker build -t authing:docs-new .
- docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWD} ${DOCKER_REPO}
- export IMAGE_NAME=${DOCKER_REPO}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
- docker tag authing:docs-new ${IMAGE_NAME}:${VERSION}
- docker push ${IMAGE_NAME}:${VERSION}
- docker image rm authing:docs-new
- docker image rm ${IMAGE_NAME}:${VERSION}
- echo $OSS_URL
- echo $OSS_REGION
- >
ossutil --access-key-id ${ALIYUN_ACCESS_KEY}
--access-key-secret ${ALIYUN_ACCESS_KEY_SECRET}
-e ${OSS_REGION} cp -r -f docs/.vuepress/dist oss://${OSS_URL}/authing-docs-v2/${VERSION}/
# 只有彻底成功了才打 tag,避免重试时版本号问题
- |
case "$CI_COMMIT_REF_NAME" in
"master")
git config --global user.name "${GITLAB_USER_NAME}"
git config --global user.email "${GITLAB_USER_EMAIL}"
# 这个傻逼 tag 一直报错
git tag -d 1.1.95
git tag -a ${VERSION} -m "${VERSION}"
git push git@git.authing.co:authing-next/authing-docs-v2.git --tags
;;
*)
;;
esac