fix: sync notification admin env into production compose
This commit is contained in:
parent
0d7eec13ce
commit
0f1fb4ea65
@ -107,6 +107,8 @@ mkdir -p "$backup_root"
|
||||
stamp="$(date +%Y%m%d%H%M%S)"
|
||||
cp -a .env "$backup_root/env-before-git-release-$stamp"
|
||||
chmod 600 "$backup_root/env-before-git-release-$stamp"
|
||||
cp -a docker-compose.yml "$backup_root/docker-compose-before-git-release-$stamp.yml"
|
||||
chmod 600 "$backup_root/docker-compose-before-git-release-$stamp.yml"
|
||||
material_env=/mnt/PoolOne/apps/youyidian-3d/.env
|
||||
test -f "$material_env"
|
||||
cp -a "$material_env" "$backup_root/material-env-before-git-release-$stamp"
|
||||
@ -128,6 +130,25 @@ def parse_env_value(raw: str) -> str:
|
||||
return value
|
||||
|
||||
|
||||
compose_path = Path('docker-compose.yml')
|
||||
compose_text = compose_path.read_text(encoding='utf-8')
|
||||
compose_marker = ' YYD_NOTIFICATION_PROJECTS_JSON: ${YYD_NOTIFICATION_PROJECTS_JSON}'
|
||||
compose_required = [
|
||||
' YYD_NOTIFICATION_ADMIN_API_SECRET: ${YYD_NOTIFICATION_ADMIN_API_SECRET}',
|
||||
' YYD_NOTIFICATION_CONFIG_ENCRYPTION_KEY: ${YYD_NOTIFICATION_CONFIG_ENCRYPTION_KEY}',
|
||||
]
|
||||
present = [line in compose_text for line in compose_required]
|
||||
if any(present) and not all(present):
|
||||
raise SystemExit('通知中心 Compose 管理环境映射不完整,拒绝猜测性修改')
|
||||
if not all(present):
|
||||
if compose_text.count(compose_marker) != 1:
|
||||
raise SystemExit('通知中心 Compose 项目配置锚点不唯一,拒绝修改')
|
||||
compose_text = compose_text.replace(
|
||||
compose_marker,
|
||||
compose_marker + '\n' + '\n'.join(compose_required),
|
||||
)
|
||||
compose_path.write_text(compose_text, encoding='utf-8')
|
||||
|
||||
env_path = Path('.env')
|
||||
lines = env_path.read_text(encoding='utf-8').splitlines()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user