Deploying one environment per branch
authorDavid Négrier <d.negrier@thecodingmachine.com>
Mon, 13 Apr 2020 13:07:04 +0000 (15:07 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Mon, 13 Apr 2020 16:44:12 +0000 (18:44 +0200)
deeployer.json [deleted file]
deeployer.libsonnet [new file with mode: 0644]

diff --git a/deeployer.json b/deeployer.json
deleted file mode 100644 (file)
index 930e6f3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-{
-  "$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json",
-  "containers": {
-     "back": {
-       "image": "thecodingmachine/workadventure-back:cd",
-       "host": "api.workadventure.test.thecodingmachine.com",
-       "ports": [8080],
-       "env": {
-         "SECRET_KEY": "tempSecretKeyNeedsToChange"
-       }
-     },
-    "front": {
-      "image": "thecodingmachine/workadventure-front:cd",
-      "host": "workadventure.test.thecodingmachine.com",
-      "ports": [80],
-      "env": {
-        "API_URL": "http://api.workadventure.test.thecodingmachine.com"
-      }
-    }
-  }
-}
diff --git a/deeployer.libsonnet b/deeployer.libsonnet
new file mode 100644 (file)
index 0000000..60c5d47
--- /dev/null
@@ -0,0 +1,24 @@
+{
+  local env = std.extVar("env"),
+  # FIXME: namespace does not work if the branch contains a "/"
+  local namespace = std.split(env.GITHUB_REF, "/")[2]
+  "$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json",
+  "containers": {
+     "back": {
+       "image": "thecodingmachine/workadventure-back:"+namespace,
+       "host": "api."+namespace+".workadventure.test.thecodingmachine.com",
+       "ports": [8080],
+       "env": {
+         "SECRET_KEY": "tempSecretKeyNeedsToChange"
+       }
+     },
+    "front": {
+      "image": "thecodingmachine/workadventure-front:"+namespace,
+      "host": namespace+".workadventure.test.thecodingmachine.com",
+      "ports": [80],
+      "env": {
+        "API_URL": "http://api."+namespace+".workadventure.test.thecodingmachine.com"
+      }
+    }
+  }
+}