From 47438bdd1a509c4ee2b70d96f474fbf1ea190120 Mon Sep 17 00:00:00 2001 From: Nicolas Sanchez Date: Thu, 12 Sep 2024 11:15:42 -0300 Subject: [PATCH] Update arena's gateway_url from staging configurator only --- .../central-europe-staging-deploy.yml | 2 +- .../controllers/arena_server_controller.ex | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/central-europe-staging-deploy.yml b/.github/workflows/central-europe-staging-deploy.yml index 55ffe6728..07484bc84 100644 --- a/.github/workflows/central-europe-staging-deploy.yml +++ b/.github/workflows/central-europe-staging-deploy.yml @@ -46,7 +46,7 @@ jobs: MIX_ENV: ${{ vars.MIX_ENV }} RELEASE: central_backend PHX_SERVER: ${{ vars.PHX_SERVER }} - PHX_HOST: ${{ vars.HOST }} + PHX_HOST: ${{ vars.PHX_HOST_STAGING }} PORT: ${{ vars.ARENA_PORT }} GOOGLE_CLIENT_ID: ${{ vars.GOOGLE_CLIENT_ID }} CONFIGURATOR_HOST: ${{ vars.CONFIGURATOR_HOST }} diff --git a/apps/configurator/lib/configurator_web/controllers/arena_server_controller.ex b/apps/configurator/lib/configurator_web/controllers/arena_server_controller.ex index 3cc4063e4..99471f8be 100644 --- a/apps/configurator/lib/configurator_web/controllers/arena_server_controller.ex +++ b/apps/configurator/lib/configurator_web/controllers/arena_server_controller.ex @@ -73,18 +73,18 @@ defmodule ConfiguratorWeb.ArenaServerController do defp update_arena_gateway_url(former_url, former_url, _arena_url), do: nil defp update_arena_gateway_url(_former_url, new_url, arena_url) do - payload = Jason.encode!(%{gateway_url: new_url}) - - arena_url = - if String.contains?(arena_url, "localhost") do - "http://" <> arena_url - else - "https://" <> arena_url - end - - spawn(fn -> - Finch.build(:post, arena_url <> "/api/update_central", [{"content-type", "application/json"}], payload) - |> Finch.request(Gateway.Finch) - end) + if System.get_env("PHX_HOST") == "central-europe-staging.championsofmirra.com" do + payload = Jason.encode!(%{gateway_url: new_url}) + + spawn(fn -> + Finch.build( + :post, + "https://" <> arena_url <> "/api/update_central", + [{"content-type", "application/json"}], + payload + ) + |> Finch.request(Gateway.Finch) + end) + end end end