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
2023-03-13 10:32:40 +00:00

103 lines
2.5 KiB
YAML

# 自定义生命周期
stages:
- gen_git-log
- build_project
- test
- 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;top:0;left:0;z-index:999;font-size:12px;color:transparent;text-decoration:none;display:none;" target="_blank" href="./git-log.html">R</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
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
when: on_success
paths:
- dist/
only:
- dev
- tags
tags:
- galaxy
test:
stage: test
script:
- cnpm run test
when: on_success
only:
- dev
tags:
- galaxy
build_image:
dependencies:
- build_project
stage: build_image
script:
- echo "docker build"
- sudo docker build --no-cache -t cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG .
- echo "docker tag"
- sudo docker tag cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG 192.168.40.153:9080/cyber-narrator/cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG
- echo "docker push"
- sudo docker push 192.168.40.153:9080/cyber-narrator/cn-ui-$CI_COMMIT_REF_NAME:$CNUI_TAG
when: on_success
only:
- dev
tags:
- galaxy
build_release_image:
dependencies:
- build_project
stage: build_image
script:
- echo 'tag名称是'
- echo $CI_COMMIT_TAG
- echo '提交的版本是'
- echo $CI_COMMIT_REF_NAME
- echo "docker build"
- sudo docker build --no-cache -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