fix-deploy-network
This commit is contained in:
@@ -142,6 +142,43 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: dockerreg.eazygame.cn/node-with-docker:22
|
image: dockerreg.eazygame.cn/node-with-docker:22
|
||||||
steps:
|
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
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user