Files
epic-go/.drone.yml
hxt d9384ded4c ci(drone): 添加 Go 模块和构建缓存
- 在 restore cache 和 rebuild cache 步骤中添加了 go-mod-cache 和 go
2025-07-08 21:14:58 +08:00

91 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

kind: pipeline
type: docker
name: default
steps:
- name: restore cache
image: drillster/drone-volume-cache
volumes:
- name: go-mod-cache
path: /go/pkg/mod
- name: go-build-cache
path: /root/.cache/go-build
settings:
restore: true
mount:
- /go/pkg/mod
- /root/.cache/go-build
backend: local
cache_key: go-mod-cache-${DRONE_BRANCH}
- name: build
image: golang:1.22
commands:
- mkdir -p /go/pkg/mod
- mkdir -p /root/.cache/go-build
- echo "test" > /go/pkg/mod/testfile
- echo "==== Before build, go/pkg/mod ===="
- ls -lR /go/pkg/mod || echo "/go/pkg/mod not found"
- echo "==== Before build, /root/.cache/go-build ===="
- ls -lR /root/.cache/go-build || echo "/root/.cache/go-build not found"
- echo "==== Before build, /go/.cache/go-build ===="
- ls -lR /go/.cache/go-build || echo "/go/.cache/go-build not found"
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go mod tidy
- go build -o main.exe .
- echo "==== After build, go/pkg/mod ===="
- ls -lR /go/pkg/mod || echo "/go/pkg/mod not found"
- echo "==== After build, /root/.cache/go-build ===="
- ls -lR /root/.cache/go-build || echo "/root/.cache/go-build not found"
- echo "==== After build, /go/.cache/go-build ===="
- ls -lR /go/.cache/go-build || echo "/go/.cache/go-build not found"
- name: rebuild cache
image: drillster/drone-volume-cache
volumes:
- name: go-mod-cache
path: /go/pkg/mod
- name: go-build-cache
path: /root/.cache/go-build
settings:
rebuild: true
mount:
- /go/pkg/mod
- /root/.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