This commit is contained in:
昔念
2026-01-26 23:45:45 +08:00
parent f27a0cb86a
commit e0680b3562

View File

@@ -22,13 +22,23 @@ clone:
steps:
# SSH初始化步骤
init-ssh:
image: alpine:latest
image: alpine/git:latest
environment:
WOODPECKER_SSH_KEY:
from_secret: WOODPECKER_SSH_KEY
commands:
- mkdir -p /root/.ssh
- touch /root/.ssh/known_hosts
- chmod 600 /root/.ssh/known_hosts
# 如果需要的话可以添加远程主机到known_hosts
# ssh-keyscan -H <your-remote-host> >> /root/.ssh/known_hosts
- |
# 设置SSH
mkdir -p ~/.ssh
echo "$${WOODPECKER_SSH_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
# 配置git
git config --global user.name "Woodpecker CI"
git config --global user.email "ci@example.com"
# 1. 缓存Go依赖加速构建
cache-go-mod: