Files
bl/.woodpecker/my-first-workflow.yaml

68 lines
2.0 KiB
Go
Raw Normal View History

2026-01-27 06:40:49 +00:00
# 触发条件仅pushmanual手动触发分支限定main
2026-01-26 10:14:44 +08:00
when:
2026-01-27 06:40:49 +00:00
event:
- push
- manual
branch: main
2026-01-26 11:07:37 +08:00
2026-01-28 12:15:35 +08:00
skip_clone: true
2026-01-26 14:06:51 +08:00
2026-01-27 12:15:35 +00:00
2026-01-28 12:15:35 +08:00
# 全局配置变量替换占位符即可使用
variables:
SCREEN_NAME: "logic_service"
REMOTE_EXE_DIR: "/opt/logic"
JSON_CONFIG_URL: "https://你的JSON配置地址.com/deploy.json"
LOG_PATH: "$HOME/run.log"
2026-01-26 14:06:51 +08:00
2026-01-28 12:15:35 +08:00
# 流水线核心步骤理顺依赖链确保各步骤依赖正确
steps:
# ========== 1. 替代clone拉取代码核心依赖 ==========
prepare:
image: debian:bookworm
2026-01-28 10:52:09 +08:00
environment:
2026-01-28 12:15:35 +08:00
WOODPECKER_SSH_KEY:
from_secret: WOODPECKER_SSH_KEY
2026-01-28 12:21:08 +08:00
CNB_ACCK:
from_secret: CNB_ACCK
2026-01-28 10:52:09 +08:00
commands:
2026-01-28 12:15:35 +08:00
# 调试验证变量是否传递
- echo "🔍 调试当前环境变量列表筛选SSH相关"
- env | grep -i ssh || echo "⚠️ 无SSH相关环境变量"
# 系统初始化
- apt update -y
- apt install -y --no-install-recommends ca-certificates curl git openssh-client openssl libssl-dev
# 清理旧SSH文件严格配置权限
- rm -rf /root/.ssh/*
- mkdir -p /root/.ssh && chmod 700 /root/.ssh
- DEPLOY_KEY_FILE="$HOME/.ssh/deploy_key"
# 关键修复SSH密钥写入EOF内无缩进
2026-01-28 10:52:09 +08:00
- |
2026-01-28 12:15:35 +08:00
cat > /root/.ssh/id_ed25519 << EOF
$WOODPECKER_SSH_KEY
EOF
chmod 600 /root/.ssh/id_ed25519
echo "✅ ED25519密钥写入完成"
2026-01-26 14:06:51 +08:00
2026-01-28 12:15:35 +08:00
# 添加GitHub主机密钥
- SSH_KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts"
- ssh-keyscan -H github.com > /root/.ssh/known_hosts
- chmod 600 /root/.ssh/known_hosts
2026-01-28 11:21:46 +08:00
2026-01-28 12:15:35 +08:00
- echo "🔍 ${#CI_REPO_CLONE_SSH_URL}调试: ${CI_REPO_CLONE_SSH_URL}"
- git config --global core.compression 0
2026-01-28 12:29:07 +08:00
- export GIT_CONFIG_URL="https://cnb:$CNB_ACCK@cnb.cool/blzing/blazing"
2026-01-28 12:26:17 +08:00
- echo "🔍 $CNB_ACCK调试 $GIT_CONFIG_URL"
- git clone --depth 1 --progress -v $GIT_CONFIG_URL
2026-01-28 12:15:35 +08:00
# 拉取代码
2026-01-28 12:17:56 +08:00
- echo "✅ 代码拉取完成"