This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/.gitlab-ci.yml
2022-07-27 13:29:54 +00:00

83 lines
2.1 KiB
YAML

# 自定义生命周期
stages:
- gen_git-log
- build_project
- build_image
cache:
key:
files:
- package.json
paths:
- node_modules
- dist/
before_script:
- export CNUI_TAG=$(date +%Y%m%d%H%M%S)
generate_git-log:
stage: gen_git-log
script:
- if (( `grep git-log.html ./public/index.html | wc -l` == 0 )); then sed -i 's+</body>+<a style="position:fixed;bottom:20px;left:40px;z-index:999;color:white;" target="_blank" href="./git-log.html">更新记录</a>\n</body>+g' ./public/index.html; echo "添加更新记录链接"; fi;
- echo "最近的100个提交记录"
- echo "<!DOCTYPE html><html><head><meta charset='utf-8'></head><body><pre>" > ./public/git-log.html
- "git log -100 --pretty=format:'%ad : %s' >> ./public/git-log.html"
- echo "</pre></body></html>" >> ./public/git-log.html
- echo "处理 git-log.html 结束"
artifacts:
paths:
- public/index.html
- public/git-log.html
only:
- dev
tags:
- galaxy
build_project:
stage: build_project
script:
- echo "npm install ..."
- cnpm install --save-dev --unsafe-perm
- echo "npm run build"
- cnpm run build
only:
- dev
- tags
tags:
- galaxy
build_image:
stage: build_image
script:
- echo "docker build"
- sudo docker build -t cn-ui:$CNUI_TAG .
- echo "docker tag"
- sudo docker tag cn-ui:$CNUI_TAG 192.168.40.153:9080/cyber-narrator/cn-ui:$CNUI_TAG
- echo "docker push"
- sudo docker push 192.168.40.153:9080/cyber-narrator/cn-ui:$CNUI_TAG
when: on_success
only:
- dev
tags:
- galaxy
build_release_image:
stage: build_image
script:
- echo 'tag名称是'
- echo $CI_COMMIT_TAG
- echo '提交的版本是'
- echo $CI_COMMIT_REF_NAME
- echo "docker build"
- sudo docker build -t cn-ui:$CI_COMMIT_TAG .
- echo "docker tag"
- sudo docker tag cn-ui:$CI_COMMIT_TAG 192.168.40.153:9080/cyber-narrator/cn-ui:$CI_COMMIT_TAG
- echo "docker push"
- sudo docker push 192.168.40.153:9080/cyber-narrator/cn-ui:$CI_COMMIT_TAG
only:
- tags
tags:
- galaxy