stages:
  - build
  - deploy

cache:
  paths:
    - out
    - node_modules/


compile_articles:
  stage: build
  # when: manual
  environment:
    name: release
  only:
    - master
  script:
    - node utils/articleAggregate.js
    - sh utils/commit.sh
    - yarn
    - npm run export
    - node utils/toJSON.js
    - rm -r /home/gitlab-runner/deploy/cms/ronghui/out
    - cp -r out /home/gitlab-runner/deploy/cms/ronghui
    # - cp -r content /home/gitlab-runner/deploy/official/out
    - echo "cms https://cmsadmin.gaorongvc.cn/ronghui/admin"


# compress_images:
#   stage: build
#   # when: manual
#   environment:
#     name: release
#   only:
#     - master
#   script:
#     - yarn
#     - sh utils/imageCompress.sh


deploy:
  stage: deploy
  # when: manual
  environment:
    name: release
  only:
    - master
  script:
    - yarn
    # - sh utils/imageCompress.sh
    - npm run export
    - node utils/toJSON.js
    - rm -rf /home/gitlab-runner/deploy/cms/ronghui/out
    - echo "预览页面已清除"
    - cp -r out /home/gitlab-runner/deploy/cms/ronghui
    # - cp -r content out
    - /home/gitlab-runner/sh/ossutil64 cp -f out oss://touhou-cms/ -r


# preview:
#   stage: deploy
#   # when: manual
#   environment:
#     name: preview
#   script:
#     - yarn
#     - npm run export
#     - rm -r /home/gitlab-runner/deploy/cms/ronghui/out
#     - cp -r out /home/gitlab-runner/deploy/cms/ronghui




