fix: init git repo on server if not exists
All checks were successful
Deploy to Server / deploy (push) Successful in 19s
All checks were successful
Deploy to Server / deploy (push) Successful in 19s
This commit is contained in:
@@ -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 文件
|
||||
|
||||
Reference in New Issue
Block a user