From c6cf11124ea45baafc0172821c5504a25f23ee86 Mon Sep 17 00:00:00 2001 From: chenchun Date: Tue, 4 Aug 2026 05:37:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20build-and-push.sh?= =?UTF-8?q?=20=E7=A1=AC=E7=BC=96=E7=A0=81=E5=87=AD=E6=8D=AE=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=BB=8E=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-and-push.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build-and-push.sh b/build-and-push.sh index c30be06..c9ae84c 100755 --- a/build-and-push.sh +++ b/build-and-push.sh @@ -13,8 +13,15 @@ FULL_IMAGE="${REGISTRY}/${OWNER}/${IMAGE}:${TAG}" # ========================================== # 1. 登录 Registry # ========================================== +# 凭据必须通过环境变量 REGISTRY_USERNAME / REGISTRY_PASSWORD 提供, +# 禁止硬编码在脚本或代码中(团队安全规则第 5 条)。 +# 使用方式: +# REGISTRY_USERNAME="<用户名>" REGISTRY_PASSWORD="<密码>" ./build-and-push.sh +: "${REGISTRY_USERNAME:?请通过环境变量 REGISTRY_USERNAME 提供 Registry 用户名}" +: "${REGISTRY_PASSWORD:?请通过环境变量 REGISTRY_PASSWORD 提供 Registry 密码}" + echo ">>> [1/3] 登录 Registry: ${REGISTRY}" -echo "0218Virtheart@2025" | docker login "${REGISTRY}" -u "chenchun@virtheart.com" --password-stdin +echo "${REGISTRY_PASSWORD}" | docker login "${REGISTRY}" -u "${REGISTRY_USERNAME}" --password-stdin # ========================================== # 2. 构建镜像