action
Some checks failed
Deploy to Server / deploy (push) Failing after 2s

This commit is contained in:
jeremygan2021
2026-03-02 15:26:43 +08:00
parent bb814061e7
commit ae2da39496

View File

@@ -57,14 +57,28 @@ jobs:
# 记录旧版本号
send "OLD_HEAD=\\\$(git rev-parse HEAD 2>/dev/null || echo '')\r"
# 拉取代码
# 拉取代码 - 可能需要 sudo 权限或者目录权限问题
send "echo 'Pulling latest code...'\r"
# 尝试直接 git pull如果失败则尝试 sudo git pull
# 但 sudo git pull 可能会因为 .git 目录的所有者问题而失败,或者需要输入密码
# 最好的方式是确保当前用户对目录有写权限。
# 既然用户提示 "Permission denied" 并且提到 "sudo",我们尝试在 git pull 前确保权限,或者用 sudo git pull
# 先尝试修正权限 (需要 sudo)
send "echo '\$password' | sudo -S chown -R \$user:\$user \$target_dir\r"
# 然后执行 git pull
send "git pull\r"
# 检查拉取是否成功
expect {
"Already up to date." { send "echo 'Code is up to date'\r" }
"Updating" { send "echo 'Code updated'\r" }
"Permission denied" {
puts "Git pull permission denied, trying with sudo..."
send "echo '\$password' | sudo -S git pull\r"
}
timeout { puts "Git pull timeout"; exit 1 }
}