# .drone.yml
kind: pipeline
name: default

steps:
- name: test
  image: golang
  commands:
  - export GOPROXY=https://mirrors.aliyun.com/goproxy/
  - go test

- name: clone_web
  image: alpine/git
  volumes:
  - name: cache
    path: /web
  commands:
  - cd /web
  - git clone https://git.shagain.club/lingling/go_echo_wol_web.git .
  - git checkout master

- name: build_web
  image: node
  volumes:
  - name: cache
    path: /web
  commands:
  - cd /web/go_echo_wol_web
  - npm install yarn
  - cd go_echo_wol_web
  - yarn
  - yarn build

- name: build
  image: golang
  volumes:
  - name: cache
    path: /go
  - name: outdir
  host:
    path: /root/web
  commands:
  - export GOPROXY=https://mirrors.aliyun.com/goproxy/
  - rm -rf ./app/*
  - cp -r /web/build ./app
  - sed 's/\/static/\/static\/static/g' ./app/index.html
  - sed 's/\/favicon.ico/\/static\/favicon.ico/g' ./app/index.html
  - sed 's/\/logo192.png/\/static\/logo192.png/g' ./app/index.html
  - sed 's/\/manifest.json/\/static\/manifest.json/g' ./app/index.html
  - go build -o main
  - cp main /root/web/