This commit is contained in:
lhx
2025-10-30 15:49:05 +08:00
parent 9a77b8c1dc
commit e6815176ae

View File

@@ -29,23 +29,22 @@ if [ $SKIP_GIT_PULL -eq 0 ]; then
read -s GIT_PASSWORD read -s GIT_PASSWORD
echo "" echo ""
# 设置git凭据 # 直接使用URL中的用户名密码进行拉取
git config credential.helper store git_url=$(git remote get-url origin)
echo "https://$GIT_USERNAME:$GIT_PASSWORD@gitea.com" > ~/.git-credentials if [[ $git_url == http* ]]; then
# 如果是http/https URL替换为包含用户名密码的URL
# 拉取代码 git_url_with_auth=$(echo $git_url | sed "s|https://|https://$GIT_USERNAME:$GIT_PASSWORD@|")
git pull $git_url_with_auth main
else
# 如果是ssh或其他格式使用expect或者让git自动处理
echo "使用凭据拉取代码..."
git pull origin main git pull origin main
fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "✓ 代码拉取成功" echo "✓ 代码拉取成功"
# 清除git凭据
rm -f ~/.git-credentials
git config --unset credential.helper
else else
echo "✗ 代码拉取失败" echo "✗ 代码拉取失败"
# 清除git凭据
rm -f ~/.git-credentials
git config --unset credential.helper
echo "是否继续部署? (y/n)" echo "是否继续部署? (y/n)"
read -r CONTINUE_DEPLOY read -r CONTINUE_DEPLOY
if [ "$CONTINUE_DEPLOY" != "y" ] && [ "$CONTINUE_DEPLOY" != "Y" ]; then if [ "$CONTINUE_DEPLOY" != "y" ] && [ "$CONTINUE_DEPLOY" != "Y" ]; then