drone自动打包配置


这个是一个go项目打包的时候需要将前端一起打包进去 所以就需要先打包前端 在把打包好的前端复制到go的静态打包目录在执行打包 这个是配置

# .drone.yml
kind: pipeline
name: default

workspace:
   base: /go
   path: src/github.com/octocat/hello-world

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

- name: clone_web
  image: alpine/git
  commands:
  - mkdir /go/web
  - ls /go/web
  - git clone https://t.shain.club/lingg/go_echo_wol_web.git /go/web
  - git checkout master

- name: build_web
  image: node
  commands:
  - cd /go/web/
  - npm install yarn
  - yarn config set registry https://registry.npm.taobao.org --global
  - yarn
  - yarn run eject
  - yarn build

- name: build
  image: golang
  volumes:
  - name: outdir
    path: /root/web
  commands:
  - rm -rf ./app/*
  - cp -r /go/web/build/* ./app/
  - sed -i 's?/static?/static/static?g' ./app/index.html
  - sed -i 's?/favicon.ico?/static/favicon.ico?g' ./app/index.html
  - sed -i 's?/logo192.png?/static/logo192.png?g' ./app/index.html
  - sed -i 's?/manifest.json?/static/manifest.json?g' ./app/index.html
  - CGO_ENABLED=0 go build -o /root/web/main
volumes:
  - name: outdir
    host:
      path: /root/web

声明:小小博客|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - drone自动打包配置


Carpe Diem and Do what I like