fix/ 修复workflow对env占位符的处理
This commit is contained in:
7
.github/workflows/docker-build-deploy.yml
vendored
7
.github/workflows/docker-build-deploy.yml
vendored
@@ -253,15 +253,16 @@ jobs:
|
||||
echo "::error::缺少 $ENV_SRC,无法部署。"
|
||||
exit 1
|
||||
fi
|
||||
if grep -Eq '=(your_|replace_with_|\\.{3}$)' "$ENV_SRC"; then
|
||||
# 仅检查「有效配置行」:跳过整行注释,避免 # KEY=your_* 示例误伤部署
|
||||
if grep -Ev '^[[:space:]]*#' "$ENV_SRC" | grep -Eq '=(your_|replace_with_|\\.{3})$'; then
|
||||
echo "::error::$ENV_SRC 仍包含占位符值,请先完善环境文件。"
|
||||
exit 1
|
||||
fi
|
||||
if grep -Eq '^DATABASE_URL=.*@localhost:' "$ENV_SRC" || grep -Eq '^REDIS_URL=redis://localhost' "$ENV_SRC"; then
|
||||
if grep -Ev '^[[:space:]]*#' "$ENV_SRC" | grep -Eq '^DATABASE_URL=.*@localhost:' || grep -Ev '^[[:space:]]*#' "$ENV_SRC" | grep -Eq '^REDIS_URL=redis://localhost'; then
|
||||
echo "::error::$ENV_SRC 包含 localhost 数据库或 Redis 地址,容器内将无法连接。"
|
||||
exit 1
|
||||
fi
|
||||
if grep -Eq '^DATABASE_URL=.*@postgresql:' "$ENV_SRC"; then
|
||||
if grep -Ev '^[[:space:]]*#' "$ENV_SRC" | grep -Eq '^DATABASE_URL=.*@postgresql:'; then
|
||||
echo "::error::$ENV_SRC 仍引用过期主机名 postgresql;当前 compose 服务名应为 postgres。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user