84 lines
2.2 KiB
Go
84 lines
2.2 KiB
Go
kind: pipeline
|
||
type: docker
|
||
name: default
|
||
|
||
steps:
|
||
- name: restore cache
|
||
image: drillster/drone-volume-cache
|
||
volumes:
|
||
- name: go-mod-cache
|
||
path: /opt/drone/cache/go-mod
|
||
- name: go-build-cache
|
||
path: /opt/drone/cache/go-build
|
||
settings:
|
||
restore: true
|
||
mount:
|
||
- /opt/drone/cache/go-mod
|
||
- /opt/drone/cache/go-build
|
||
backend: local
|
||
cache_key: go-mod-cache-${DRONE_BRANCH}
|
||
|
||
- name: build
|
||
image: golang:1.22
|
||
commands:
|
||
- mkdir -p /opt/drone/cache/go-mod
|
||
- mkdir -p /opt/drone/cache/go-build
|
||
- go env -w GOMODCACHE=/opt/drone/cache/go-mod
|
||
- go env -w GOCACHE=/opt/drone/cache/go-build
|
||
- go env -w GO111MODULE=on
|
||
- go env -w GOPROXY=https://goproxy.cn,direct
|
||
- go mod tidy
|
||
- go build -o main.exe .
|
||
- echo "==== After build, /opt/drone/cache/go-mod ===="
|
||
- ls -lR /opt/drone/cache/go-mod || echo "/opt/drone/cache/go-mod not found"
|
||
- echo "==== After build, /opt/drone/cache/go-build ===="
|
||
- ls -lR /opt/drone/cache/go-build || echo "/opt/drone/cache/go-build not found"
|
||
|
||
- name: rebuild cache
|
||
image: drillster/drone-volume-cache
|
||
volumes:
|
||
- name: go-mod-cache
|
||
path: /opt/drone/cache/go-mod
|
||
- name: go-build-cache
|
||
path: /opt/drone/cache/go-build
|
||
settings:
|
||
rebuild: true
|
||
mount:
|
||
- /opt/drone/cache/go-mod
|
||
- /opt/drone/cache/go-build
|
||
backend: local
|
||
cache_key: go-mod-cache-${DRONE_BRANCH}
|
||
|
||
- name: upload
|
||
image: appleboy/drone-scp
|
||
settings:
|
||
host: 193.112.151.199
|
||
username: root
|
||
password:
|
||
from_secret: scp_password
|
||
port: 222
|
||
source:
|
||
- main.exe
|
||
- scripts/start.sh
|
||
target: /opt/dockeropt/epic-go
|
||
|
||
# 可选:远程重启服务
|
||
# - name: restart
|
||
# image: appleboy/ssh
|
||
# settings:
|
||
# host: 你的服务器IP或域名
|
||
# username: 你的SSH用户名
|
||
# password:
|
||
# from_secret: scp_password
|
||
# port: 22
|
||
# script:
|
||
# - cd /your/deploy/path/
|
||
# - chmod +x start.sh
|
||
# - ./start.sh
|
||
volumes:
|
||
- name: go-mod-cache
|
||
host:
|
||
path: /opt/drone/cache/go-mod
|
||
- name: go-build-cache
|
||
host:
|
||
path: /opt/drone/cache/go-build |