fix: guard secret_key_base config by RELEASE_NAME

Each release only requires its own secret key:
- centralcloud_my  needs MY_SECRET_KEY_BASE
- centralcloud_staff needs OPS_SECRET_KEY_BASE

RELEASE_NAME is set automatically by Elixir release scripts at startup.
Fixes startup crash when staff release ran without MY_SECRET_KEY_BASE.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Mikael Hugo 2026-05-11 13:57:07 +02:00
parent a4ca979cc2
commit 1758b2465e

View file

@ -2,12 +2,18 @@ import Config
# Runtime secrets — each release only requires its own secret key
if config_env() == :prod do
config :centralcloud_my, CentralcloudMy.Endpoint,
secret_key_base: System.get_env("MY_SECRET_KEY_BASE") || System.fetch_env!("MY_SECRET_KEY_BASE")
# RELEASE_NAME is set by the Elixir release scripts at startup.
# Each release only requires its own secret key.
release = System.get_env("RELEASE_NAME", "")
# STAFF_SECRET_KEY_BASE only required when running the centralcloud_staff release
if staff_key = System.get_env("OPS_SECRET_KEY_BASE") do
config :centralcloud_staff, CentralcloudStaff.Endpoint, secret_key_base: staff_key
if release != "centralcloud_staff" do
config :centralcloud_my, CentralcloudMy.Endpoint,
secret_key_base: System.fetch_env!("MY_SECRET_KEY_BASE")
end
if release != "centralcloud_my" do
config :centralcloud_staff, CentralcloudStaff.Endpoint,
secret_key_base: System.fetch_env!("OPS_SECRET_KEY_BASE")
end
end