stages:
  - build
  - deploy

cache:
  paths:
    - out
    - node_modules/

compile_articles_and_preview:
  stage: build
  # when: manual
  environment:
    name: release
  only:
    - master
  script:
    - yarn
    - node utils/articleAggregate.js
    - sh utils/imageCompress.sh
    - sh utils/commit.sh
    - npm run export
    - rm -rf /home/gitlab-runner/deploy/cms/ficus/out #/home/gitlab-runner/deploy/official/out/
    - cp -r out /home/gitlab-runner/deploy/cms/ficus/ #deploy/official
    # - rm -r /home/gitlab-runner/deploy/official/out
    # - cp -r out/ /home/gitlab-runner/deploy/official/
    - echo "cms https://cmsadmin.gaorongvc.cn/ficus/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
#     - rm -rf /home/gitlab-runner/deploy/cms/ficus/out #/home/gitlab-runner/deploy/official/out/
#     - echo "预览页面已清除"
#     - cp -r out /home/gitlab-runner/deploy/cms/ficus/ #deploy/official
#     - /home/gitlab-runner/sh/ossutil64 cp -f out oss://gaorong-web/ -r


# preview:
#   stage: deploy
#   # when: manual
#   environment:
#     name: preview
#   # artifacts:
#   #   name: 'package'
#   #   untracked: true
#   #   expire_in: 12 hours
#   #   paths: 
#   #     - out
#   script:
#     - yarn
#     # - sh utils/imageCompress.sh
#     - npm run export
#     - rm -rf /home/gitlab-runner/deploy/cms/official/out #/home/gitlab-runner/deploy/official/out/
#     - cp -r out /home/gitlab-runner/deploy/cms/official/ #deploy/official
#     # - rm -r /home/gitlab-runner/deploy/official/out
#     # - cp -r out/ /home/gitlab-runner/deploy/official/
#     - echo "预览网站：http://preview.gaorongvc.cn:9945/"




