fix: init git repo on server if not exists
All checks were successful
Deploy to Server / deploy (push) Successful in 19s

This commit is contained in:
爽哒哒
2026-03-21 02:38:22 +08:00
parent b37155f657
commit bba69d662b
4 changed files with 16 additions and 311 deletions

View File

@@ -28,12 +28,21 @@ jobs:
# 3. 拉取 Git 最新代码
echo -e "\n===== 拉取 Git 代码 ====="
if ! git pull; then
echo "警告Git pull 失败,尝试强制同步远程代码..."
git fetch --all
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git reset --hard origin/$CURRENT_BRANCH
git pull
REPO_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git"
if [ ! -d ".git" ]; then
echo "不是 git 仓库,初始化并拉取代码..."
git init
git remote add origin $REPO_URL
git fetch origin
git checkout -b main origin/main
else
git remote set-url origin $REPO_URL
if ! git pull; then
echo "警告Git pull 失败,尝试强制同步远程代码..."
git fetch --all
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git reset --hard origin/$CURRENT_BRANCH
fi
fi
# 4. 创建/更新 .env 文件