更新docker-push与github action,防止提交覆盖docker hub版本

This commit is contained in:
yyhuni
2025-12-15 12:18:22 +08:00
parent 0ffab3958d
commit 04f320f823
2 changed files with 15 additions and 7 deletions

View File

@@ -2,12 +2,8 @@ name: Build and Push Docker Images
on:
push:
branches: [main]
paths:
- 'backend/**'
- 'frontend/**'
- 'docker/**'
- '.github/workflows/**'
tags:
- 'v*' # 只在推送 v 开头的 tag 时触发(如 v1.0.0
workflow_dispatch: # 手动触发
# 并发控制:同一分支只保留最新的构建,取消之前正在运行的

View File

@@ -188,11 +188,23 @@ main() {
echo "=========================================="
echo ""
log_info "用户: $DOCKER_USER"
log_info "版本: $VERSION"
log_warn "版本: ${VERSION}"
log_info "推送: $PUSH"
[ -n "$PLATFORM" ] && log_info "平台: $PLATFORM"
echo ""
# 确认版本号,防止误覆盖
if [ "$PUSH" = "yes" ]; then
echo -e "${YELLOW}[!] 请确认版本号 ${VERSION} 是否正确${NC}"
echo -e "${YELLOW} 如需修改,请编辑 VERSION 文件${NC}"
read -p "确认推送?(y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
log_info "已取消"
exit 0
fi
fi
check_docker_login
# 切换到项目根目录