stages:
  - build
  - deploy

cache:
  paths:
    - out
    - node_modules/


compile_articles:
  stage: build
  # when: manual
  environment:
    name: release
  only:
    - master
  script:
    - git remote show origin
    - yarn
    - node utils/articleAggregate.js
    - sh utils/commit.sh

# 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
  # artifacts:
  #   name: 'package'
  #   untracked: true
  #   expire_in: 12 hours
  #   paths: 
  #     - out
  script:
    - rm -r /home/gitlab-runner/deploy/cms/ronghui
    - cp -r . /home/gitlab-runner/deploy/cms/ronghui




