stages:
  - build
  - deploy

cache:
  paths:
    - out
    - node_modules/


compile_articles:
  stage: build
  # when: manual
  environment:
    name: release
  only:
    - master
  script:
    - yarn
    - node utils/articleAggregate.js
    - sh utils/commit.sh
    - npm run export
    - rm -r /home/gitlab-runner/deploy/cms/ronghui/out
    - cp -r out /home/gitlab-runner/deploy/cms/ronghui


# 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
    - rm -rf /home/gitlab-runner/deploy/cms/ronghui/out
    - echo "预览页面已清除"
    - cp -r out /home/gitlab-runner/deploy/cms/ronghui
    - /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




