fix-deploy-network
Some checks failed
CI / build-and-test (push) Successful in 15m29s
CI / deploy (push) Failing after 3m50s

This commit is contained in:
SpecialX
2026-02-25 18:03:32 +08:00
parent dcc946f48c
commit ef9b987653

View File

@@ -142,6 +142,43 @@ jobs:
container:
image: dockerreg.eazygame.cn/node-with-docker:22
steps:
- name: 🌐 Setup Network (Dynamic)
run: |
# 1. 动态获取 Docker 网关 IP
# 尝试多种方式获取网关 IP
GATEWAY_IP=""
# 尝试使用 ip route (如果可用)
if command -v ip >/dev/null 2>&1; then
GATEWAY_IP=$(ip route show | grep default | awk '{print $3}')
fi
# 如果 ip 命令不可用,尝试 hostname -I 推断
if [ -z "$GATEWAY_IP" ]; then
CURRENT_IP=$(hostname -I 2>/dev/null | awk '{print $1}')
if [ -n "$CURRENT_IP" ]; then
GATEWAY_IP=$(echo "$CURRENT_IP" | sed 's/\.[0-9]*$/.1/')
fi
fi
# 兜底
if [ -z "$GATEWAY_IP" ]; then
echo "Warning: Could not detect gateway IP, using fallback 172.17.0.1"
GATEWAY_IP="172.17.0.1"
fi
echo "Detected Docker Gateway: $GATEWAY_IP"
# 2. 配置 Host 解析 (解决 gittea.eazygame.cn 无法访问的问题)
# 注意:需要容器内有 root 权限
if [ "$(id -u)" -eq 0 ]; then
echo "$GATEWAY_IP gittea.eazygame.cn" >> /etc/hosts
cat /etc/hosts
else
echo "Warning: Not root, cannot modify /etc/hosts"
fi
- name: Download artifacts
uses: actions/download-artifact@v3
with: