From ffc5f9d0a934f00a1a7a58e9f09f15513f45b3d2 Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Wed, 26 Feb 2020 09:02:22 -0600
Subject: [PATCH] Add config handling for metobs versus metobs-test

---
 ci/build.sh    |  8 ++++++++
 publishconf.py | 13 ++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/ci/build.sh b/ci/build.sh
index 1c3ba9e4..a2f842f0 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -11,6 +11,14 @@ elif [[ "${os_kind}" == "centos" ]]; then
     source ~/.bashrc
 fi
 
+if [[ -z "$METOBS_SITE_DEST" ]]; then
+    if [[ "$CI_COMMIT_BRANCH" == "develop" ]]; then
+        METOBS_SITE_DEST="metobs-test"
+    else
+        METOBS_SITE_DEST="metobs"
+    fi
+fi
+
 # create or update the existing environment to the newest pelican version
 conda env update -p "${PWD}/rain_site_env" -f "${SCRIPT_DIR}/build_environment.yml"
 conda activate "${PWD}/rain_site_env"
diff --git a/publishconf.py b/publishconf.py
index 640036af..fbf952c4 100755
--- a/publishconf.py
+++ b/publishconf.py
@@ -6,8 +6,7 @@ sys.path.append(os.curdir)
 from pelicanconf import *  # noqa
 
 JS_CONF_VARS = {
-    # FIXME: Figure out how to make this `metobs` on master, `metobs-test` on develop
-    'METOBS_API_URL': 'https://metobs-test.ssec.wisc.edu',
+    'METOBS_API_URL': 'https://metobs.ssec.wisc.edu',
     'QUICKLOOKS_FORMAT': 'new',
 }
 
@@ -23,4 +22,12 @@ DELETE_OUTPUT_DIRECTORY = True
 # Following items are often useful when publishing
 
 #DISQUS_SITENAME = ""
-#GOOGLE_ANALYTICS = ""
\ No newline at end of file
+#GOOGLE_ANALYTICS = ""
+
+# Handle things differently if we are on metobs-test versus metobs
+is_test_site = os.environ.get('METOBS_SITE_DEST', 'metobs') == 'metobs-test'
+if is_test_site:
+    JS_CONF_VARS['METOBS_API_URL'] = 'https://metobs-test.ssec.wisc.edu'
+    SITEURL = 'https://metobs-test.ssec.wisc.edu'
+
+print("Rendering site for base URL: {}".format(SITEURL))
\ No newline at end of file
-- 
GitLab