guanghulab/dev-nodes/gl-push.sh
2026-05-10 13:12:44 +08:00

48 lines
2.2 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# gl-push.sh — 光湖智能上传脚本 · 三层网络降级方案
# 用法: bash gl-push.sh "提交信息"
# 要求: git 已配置PAT token 已通过 git config credential.helper store 存储
set -euo pipefail
REPO_URL="https://github.com/qinfendebingshuo/guanghulab.git"
PROXY_URL="https://ghproxy.com/https://github.com/qinfendebingshuo/guanghulab.git"
MSG="${1:-"📤 开发者上传 $(date +%Y-%m-%dT%H:%M)"}"
echo "🐙 光湖代码上传中..."
git add .
git commit -m "$MSG" 2>/dev/null || echo " 无新提交,直接推送"
# ── 层级1直连 HTTPS ──────────────────────────────────────────────────────
echo "🔗 [层级1] 尝试直连 GitHub..."
if git push origin main 2>/dev/null; then
echo "✅ 直连上传成功!铸渊已接收。"
exit 0
fi
# ── 层级2ghproxy 镜像加速 ───────────────────────────────────────────────
echo "⚠️ 直连失败,切换镜像通道..."
git remote set-url origin "$PROXY_URL"
if git push origin main 2>/dev/null; then
echo "✅ 镜像通道上传成功!铸渊已接收。"
git remote set-url origin "$REPO_URL"
exit 0
fi
git remote set-url origin "$REPO_URL"
# ── 层级3SSH ────────────────────────────────────────────────────────────
echo "⚠️ 镜像也失败,尝试 SSH 通道..."
SSH_URL="git@github.com:qinfendebingshuo/guanghulab.git"
git remote set-url origin "$SSH_URL"
if git push origin main; then
echo "✅ SSH 通道上传成功!铸渊已接收。"
git remote set-url origin "$REPO_URL"
exit 0
fi
git remote set-url origin "$REPO_URL"
# ── 全部失败 ──────────────────────────────────────────────────────────────
echo "❌ 三层网络均不通,请联系知秋处理。"
echo " 可尝试手动命令: git push git@github.com:qinfendebingshuo/guanghulab.git main"
exit 1