kind: pipeline
type: docker
name: master
steps:
  - name: restore-cache
    image: meltwater/drone-cache
    settings:
      backend: filesystem
      restore: true
      cache_key: node_modules-taskvue
      archive_format: gzip
      filesystem_cache_root: "/var/lib/cache"
      mount:
        - node_modules
    volumes:
      - name: cache
        path: "/var/lib/cache"
  # Do stuff..
  - name: install
    image: node:14
    commands:
      - yarn config set registry https://registry.npm.taobao.org --global
      - yarn config set disturl https://npm.taobao.org/dist --global
      - yarn install
  - name: rebuild-cache
    image: meltwater/drone-cache
    settings:
      backend: filesystem
      rebuild: true
      cache_key: node_modules-taskvue
      archive_format: gzip
      filesystem_cache_root: "/var/lib/cache"
      mount:
        - 'node_modules'
    volumes:
      - name: cache
        path: "/var/lib/cache"
  # Do stuff..
  - name: build
    image: node:14
    commands:
      - yarn build
  - name: scp files
    image: appleboy/drone-scp
    settings:
      host: 121.41.13.10
      username:
        from_secret: pro_user
      password:
        from_secret: pro_pass
      port: 22
      target: /data/data/wwwroot/sws.oa00.com
      source: dist/*
  - name: ssh
    image: appleboy/drone-ssh
    settings:
      host: 121.41.13.10
      username:
        from_secret: pro_user
      password:
        from_secret: pro_pass
      port: 22
      script:
        - cd /data/data/wwwroot/sws.oa00.com
        - \cp -rf dist/* ./
        - rm -rf dist
volumes:
  - name: cache
    host:
      path: "/tmp/cache"
trigger:
  branch:
    - master
  event:
    - push
    - merge
---
kind: pipeline
type: docker
name: prod
steps:
  - name: restore-cache
    image: meltwater/drone-cache
    settings:
      backend: filesystem
      restore: true
      cache_key: node_modules-taskvue
      archive_format: gzip
      filesystem_cache_root: "/var/lib/cache"
      mount:
        - node_modules
    volumes:
      - name: cache
        path: "/var/lib/cache"
  # Do stuff..
  - name: install
    image: node:14
    commands:
      - yarn config set registry https://registry.npm.taobao.org --global
      - yarn config set disturl https://npm.taobao.org/dist --global
      - yarn install
  - name: rebuild-cache
    image: meltwater/drone-cache
    settings:
      backend: filesystem
      rebuild: true
      cache_key: node_modules-taskvue
      archive_format: gzip
      filesystem_cache_root: "/var/lib/cache"
      mount:
        - 'node_modules'
    volumes:
      - name: cache
        path: "/var/lib/cache"
  # Do stuff..
  - name: build
    image: node:14
    commands:
      - yarn build

  - name: cp ftp
    image: cschlosser/drone-ftps
    environment:
      PLUGIN_HOSTNAME: 123.56.203.112:21
      FTP_USERNAME:
        from_secret: ftp_username
      FTP_PASSWORD:
        from_secret: ftp_password
      PLUGIN_SECURE: false
      PLUGIN_CHMOD: false
      PLUGIN_DEST_DIR: /v6
      PLUGIN_SRC_DIR: /dist
volumes:
  - name: cache
    host:
      path: "/tmp/cache"
trigger:
  branch:
    - prod
  event:
    - push
    - merge