<commit_before>stages:
  - test
  - build
  - deploy

variables:
  docker_tag_name: "silverblog/silverblog"

build_demo:
  services:
    - docker:dind
  tags:
    - docker-build
  stage: build
  only:
    - nightly
  script:
    - rm -rf .git
    - docker build -t registry.git.reallserver.cn/${docker_tag_name}:demo -f ./.develop/demo/Dockerfile .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.git.reallserver.cn
    - docker push registry.git.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>.silverblog.org "docker-compose down && docker pull registry.git.reallserver.cn/${docker_tag_name}:demo && 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-buildin .
    - echo ${docker_hub_passwd} | docker login -u <PASSWORD>7002 --password-stdin
    - echo ${docker_hub_passwd} | docker login -u <EMAIL> registry.cn-hangzhou.aliyuncs.com --password-stdin
    - 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 push --set-upstream <EMAIL>:SilverBlogTeam/silverblog.git HEAD:refs/heads/$CI_COMMIT_REF_NAME
    - git push --set-upstream <EMAIL>:silverblogteam/silverblog.git HEAD:refs/heads/$CI_COMMIT_REF_NAME
    - git clone https://git.reallserver.cn/SilverBlog/SilverBlog.wiki.git wiki
    - cd wiki
    - git push -f --set-upstream <EMAIL>:SilverBlogTeam/silverblog.wiki.git HEAD:refs/heads/master
    - git push -f --set-upstream <EMAIL>:silverblogteam/silverblog.wiki.git HEAD:refs/heads/master



build_test_env:
  services:
    - docker:dind
  tags:
    - docker-build
  when: manual
  script:
    - docker build -t registry.git.reallserver.cn/${docker_tag_name}:test_env -f ./.develop/unit_test/Dockerfile .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.git.reallserver.cn
    - docker push registry.git.reallserver.cn/${docker_tag_name}:test_env

unit_test_develop:<commit_msg>添加Release<commit_after>stages:
  - test
  - build
  - deploy

variables:
  docker_tag_name: "silverblog/silverblog"

build_demo:
  services:
    - docker:dind
  tags:
    - docker-build
  stage: build
  only:
    - nightly
  script:
    - rm -rf .git
    - docker build -t registry.git.reallserver.cn/${docker_tag_name}:demo -f ./.develop/demo/Dockerfile .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.git.reallserver.cn
    - docker push registry.git.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 registry.git.reallserver.cn/${docker_tag_name}:demo && 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-buildin .
    - echo ${docker_hub_passwd} | docker login -u qwe7002 --password-stdin
    - echo ${docker_hub_passwd} | docker login -u <EMAIL> registry.cn-hangzhou.aliyuncs.com --password-stdin
    - 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
  script:
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" > deploy.key
    - chmod 0600 deploy.key
    - ssh-add deploy.key
    - git push --set-upstream <EMAIL>:SilverBlogTeam/silverblog.git HEAD:refs/heads/$CI_COMMIT_REF_NAME
    - git push --set-upstream <EMAIL>:<EMAIL>blogteam/silverblog.git HEAD:refs/heads/$CI_COMMIT_REF_NAME
    - git clone https://git.reallserver.cn/SilverBlog/SilverBlog.wiki.git wiki
    - cd wiki
    - git push -f --set-upstream <EMAIL>:SilverBlogTeam/silverblog.wiki.git HEAD:refs/heads/master
    - git push -f --set-upstream <EMAIL>:silverblogteam/silverblog.wiki.git HEAD:refs/heads/master



build_test_env:
  services:
    - docker:dind
  tags:
    - docker-build
  when: manual
  script:
    - docker build -t registry.git.reallserver.cn/${docker_tag_name}:test_env -f ./.develop/unit_test/Dockerfile .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.git.reallserver.cn
    - docker push registry.git.reallserver.cn/${docker_tag_name}:test_env

unit_test_develop:
{'fraction_non_alphanumeric': 0.1256860592755214, 'fraction_numerical': 0.0043907793633369925, 'mean_word_length': 3.2053846153846153, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '1050571', 'n_tokens_mistral': 2101, 'n_tokens_neox': 1959, 'n_words': 366}