Files
epic-go/.drone.yml
hxt 92f0cc7485 ci(drone): 添加 Go 模块和构建缓存
- 在 restore cache 和 rebuild cache 步骤中添加了 go-mod-cache 和 go
2025-07-10 20:27:48 +08:00

51 lines
1.3 KiB
Go

kind: pipeline
type: docker
name: default
trigger:
event:
- manual
- custom
steps:
- name: build
image: golang:1.22
commands:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go mod tidy
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main main.go
- ls -la main
- name: upload
image: appleboy/drone-scp
settings:
host: 193.112.151.199
username: root
password:
from_secret: scp_password
port: 222
source:
- main
# - scripts/start.sh
target: /opt/dockeropt/epic-go
- name: restart epic-go container
image: appleboy/drone-ssh
settings:
host: 193.112.151.199
username: root
password:
from_secret: scp_password
port: 222
script:
- echo "=== 检查文件是否存在 ==="
- ls -la /opt/dockeropt/epic-go/
- echo "=== 检查文件类型 ==="
- file /opt/dockeropt/epic-go/main
- echo "=== 设置执行权限 ==="
- chmod +x /opt/dockeropt/epic-go/main
- echo "=== 检查依赖库 ==="
- ldd /opt/dockeropt/epic-go/main || echo "静态链接或依赖库检查失败"
- echo "=== 重启容器 ==="
- docker restart epic-go