ci(drone): 添加 Go 模块和构建缓存
- 在 restore cache 和 rebuild cache 步骤中添加了 go-mod-cache 和 go
This commit is contained in:
34
.drone.yml
34
.drone.yml
@@ -22,25 +22,8 @@ steps:
|
|||||||
image: golang:1.22
|
image: golang:1.22
|
||||||
commands:
|
commands:
|
||||||
- mkdir -p /opt/drone/cache/go-mod
|
- mkdir -p /opt/drone/cache/go-mod
|
||||||
- mkdir -p /opt/drone/cache/go-build
|
- echo "drone test" > /opt/drone/cache/go-mod/drone_testfile
|
||||||
- go env -w GOMODCACHE=/opt/drone/cache/go-mod
|
- ls -lR /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"
|
|
||||||
- echo "==== Whoami and permissions ===="
|
|
||||||
- whoami
|
|
||||||
- id
|
|
||||||
- ls -ld /opt/drone/cache/go-mod
|
|
||||||
- ls -ld /opt/drone/cache/go-build
|
|
||||||
- go env GOMODCACHE
|
|
||||||
- go env GOCACHE
|
|
||||||
- touch /opt/drone/cache/go-mod/testfile_from_build
|
|
||||||
|
|
||||||
- name: rebuild cache
|
- name: rebuild cache
|
||||||
image: drillster/drone-volume-cache
|
image: drillster/drone-volume-cache
|
||||||
@@ -57,19 +40,6 @@ steps:
|
|||||||
backend: local
|
backend: local
|
||||||
cache_key: go-mod-cache-${DRONE_BRANCH}
|
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
|
# - name: restart
|
||||||
# image: appleboy/ssh
|
# image: appleboy/ssh
|
||||||
|
|||||||
Reference in New Issue
Block a user