<commit_before>stages:
  - build
  - test
  - deploy

variables:
  docker_tag_name: "silverblog/silverblog"

build_demo:
  services:
  - docker:dind
  tags:
  - docker-build
  stage: build
  only:
  - nightly
  script:
  - docker build -t docker.reallserver.cn/${docker_tag_name}:demo -f ./.develop/demo/Dockerfile .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN docker.reallserver.cn
  - docker push docker.reallserver.cn/${docker_tag_name}:demo
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" > deploy.key
  - chmod 0600 deploy.key
  - ssh-add deploy.key
  - ssh <EMAIL> "docker-compose down && docker pull docker.reallserver.cn/${docker_tag_name}:demo && bash /home/qwe7002/dockerclean.sh && docker-compose up -d"

build_docker:
  services:
  - docker:dind
  tags:
  - docker-build
  stage: build
  only:
  - master
  script:
  - docker build -t ${docker_tag_name} -f ./example/Dockerfile .
  - docker build -t ${docker_tag_name}:buildin -f ./example/Dockerfile .
  - docker login -u qwe7002 -p ${docker_hub_passwd}
  - docker login -u <EMAIL> -p ${docker_hub_passwd} registry.cn-hangzhou.aliyuncs.com
  - docker tag ${docker_tag_name} registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}
  - docker tag ${docker_tag_name}:buildin registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}:buildin
  - docker push ${docker_tag_name}
  - docker push registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}
  - docker push ${docker_tag_name}:buildin
  - docker push registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}:buildin
release_github:
  stage: deploy
  only:
  - master
  - nightly
  script:
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" > deploy.key
  - chmod 0600 deploy.key
  - ssh-add deploy.key
  - git config --global http.https://github.com.proxy ${proxy}
  - git push --set-upstream https://${github_key}@github.com/SilverBlogTeam/silverblog.git HEAD:$CI_COMMIT_REF_NAME
  - git push --set-upstream <EMAIL>:qwe7002/silverblog.git HEAD:$CI_COMMIT_REF_NAME
  - git clone https://git.reallserver.cn/SilverBlog/SilverBlog.wiki.git wiki
  - cd wiki
  - git push -f --set-upstream https://${github_key}@github.com/SilverBlogTeam/silverblog.wiki.git HEAD:master
  - git push -f --set-upstream <EMAIL>:qwe7002/silverblog.wiki.git HEAD:master


build_test_env:
  services:
  - docker:dind
  tags:
  - docker-build
  stage: build
  only:
  - develop
  script:
  - docker pull docker.reallserver.cn/${docker_tag_name}:test_env || true
  - echo -e "RUN apk add --no-cache nginx" >> ./example/Dockerfile
  - docker build --cache-from docker.reallserver.cn/${docker_tag_name}:test_env -t docker.reallserver.cn/${docker_tag_name}:test_env -f ./example/Dockerfile .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN docker.reallserver.cn
  - docker push docker.reallserver.cn/${docker_tag_name}:test_env

unit_test_develop:
  image: docker.reallserver.cn/silverblog/silverblog:test_env
  stage: test
  only:
  - develop
  script:
  - cd install<commit_msg>修改启动脚本<commit_after>stages:
  - build
  - test
  - deploy

variables:
  docker_tag_name: "silverblog/silverblog"

build_demo:
  services:
  - docker:dind
  tags:
  - docker-build
  stage: build
  only:
  - nightly
  script:
  - docker build -t docker.reallserver.cn/${docker_tag_name}:demo -f ./.develop/demo/Dockerfile .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN docker.reallserver.cn
  - docker push docker.reallserver.cn/${docker_tag_name}:demo
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" > deploy.key
  - chmod 0600 deploy.key
  - ssh-add deploy.key
  - ssh <EMAIL> "docker-compose down && docker pull docker.reallserver.cn/${docker_tag_name}:demo && bash /home/qwe7002/dockerclean.sh && docker-compose up -d"

build_docker:
  services:
  - docker:dind
  tags:
  - docker-build
  stage: build
  only:
  - master
  script:
  - docker build -t ${docker_tag_name} -f ./example/Dockerfile .
  - docker build -t ${docker_tag_name}:buildin -f ./example/Dockerfile .
  - docker login -u qwe7002 -p ${docker_hub_passwd}
  - docker login -u <EMAIL> -p ${docker_hub_passwd} registry.cn-hangzhou.aliyuncs.com
  - docker tag ${docker_tag_name} registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}
  - docker tag ${docker_tag_name}:buildin registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}:buildin
  - docker push ${docker_tag_name}
  - docker push registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}
  - docker push ${docker_tag_name}:buildin
  - docker push registry.cn-hangzhou.aliyuncs.com/${docker_tag_name}:buildin
release_github:
  stage: deploy
  only:
  - master
  - nightly
  script:
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" > deploy.key
  - chmod 0600 deploy.key
  - ssh-add deploy.key
  - git config --global http.https://github.com.proxy ${proxy}
  - git push --set-upstream https://${github_key}@github.com/SilverBlogTeam/silverblog.git HEAD:$CI_COMMIT_REF_NAME
  - git push --set-upstream <EMAIL>:qwe7002/silverblog.git HEAD:$CI_COMMIT_REF_NAME
  - git clone https://git.reallserver.cn/SilverBlog/SilverBlog.wiki.git wiki
  - cd wiki
  - git push -f --set-upstream https://${github_key}@github.com/SilverBlogTeam/silverblog.wiki.git HEAD:master
  - git push -f --set-upstream <EMAIL>:qwe7002/silverblog.wiki.git HEAD:master


build_test_env:
  services:
  - docker:dind
  tags:
  - docker-build
  stage: build
  only:
  - develop
  script:
  - docker pull docker.reallserver.cn/${docker_tag_name}:test_env || true
  - echo " && apk add --no-cache nginx" >> ./example/Dockerfile
  - docker build --cache-from docker.reallserver.cn/${docker_tag_name}:test_env -t docker.reallserver.cn/${docker_tag_name}:test_env -f ./example/Dockerfile .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN docker.reallserver.cn
  - docker push docker.reallserver.cn/${docker_tag_name}:test_env

unit_test_develop:
  image: docker.reallserver.cn/silverblog/silverblog:test_env
  stage: test
  only:
  - develop
  script:
  - cd install
{'fraction_non_alphanumeric': 0.13152576625126305, 'fraction_numerical': 0.008083529808016167, 'mean_word_length': 3.603875968992248, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '53881', 'n_tokens_mistral': 2376, 'n_tokens_neox': 2202, 'n_words': 421}