chore: 更新部署脚本 deploy-docker.sh
Some checks failed
Build and Push Backend / docker (push) Failing after 5s
Some checks failed
Build and Push Backend / docker (push) Failing after 5s
This commit is contained in:
@@ -7,9 +7,9 @@ cd "$SCRIPT_DIR"
|
|||||||
|
|
||||||
prompt_yes_no() {
|
prompt_yes_no() {
|
||||||
local prompt="$1"
|
local prompt="$1"
|
||||||
local default_no_text="${2:-[y/N]}"
|
local choice_hint="${2:-[y/N]}"
|
||||||
local answer
|
local answer
|
||||||
read -r -p "$prompt $default_no_text " answer || true
|
read -r -p "$prompt $choice_hint " answer || true
|
||||||
answer="${answer:-}"; answer="${answer,,}"
|
answer="${answer:-}"; answer="${answer,,}"
|
||||||
[[ "$answer" == "y" || "$answer" == "yes" ]]
|
[[ "$answer" == "y" || "$answer" == "yes" ]]
|
||||||
}
|
}
|
||||||
@@ -27,15 +27,20 @@ if [[ "$CURRENT_BRANCH" != "master" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! prompt_yes_no "你跑测试了吗?要不要我帮你跑?"; then
|
if prompt_yes_no "你跑测试了吗?确认已跑请输入 y"; then
|
||||||
echo "跳过测试执行。"
|
echo "已确认测试执行完毕。"
|
||||||
else
|
else
|
||||||
|
if prompt_yes_no "需要我帮你跑测试吗?"; then
|
||||||
echo "开始执行测试: mvn test"
|
echo "开始执行测试: mvn test"
|
||||||
if ! mvn test; then
|
if ! mvn test; then
|
||||||
echo "测试未通过,部署流程终止。"
|
echo "测试未通过,部署流程终止。"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "测试通过。"
|
echo "测试通过。"
|
||||||
|
else
|
||||||
|
echo "错误: 未执行测试,部署流程终止。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! prompt_yes_no "你备份数据库了吗?确认已备份请输入 y"; then
|
if ! prompt_yes_no "你备份数据库了吗?确认已备份请输入 y"; then
|
||||||
@@ -53,6 +58,11 @@ if ! git -C "$SCRIPT_DIR" diff --quiet; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$(git -C "$SCRIPT_DIR" ls-files --others --exclude-standard)" ]]; then
|
||||||
|
echo "错误: 检测到未跟踪的文件,请清理或加入版本控制后再试。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if ! git -C "$SCRIPT_DIR" diff --cached --quiet; then
|
if ! git -C "$SCRIPT_DIR" diff --cached --quiet; then
|
||||||
echo "错误: 检测到未提交的暂存修改,请提交后再试。"
|
echo "错误: 检测到未提交的暂存修改,请提交后再试。"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user