made with Findka

Script for automating Datomic Cloud Ion push + deploy

10 May 2019

(ns deploy.core
  (:require [cljs.reader :refer [read-string]]
            [ :as shell]))

(defn sh [& args]
  (let [result (apply shell/sh args)]
    (if (= 0 (:exit result))
      (:out result)
      (throw (ex-info (:err result) {})))))

(let [push-out (sh "clojure" "-A:dev" "-m" "" "{:op :push}") ; optionally: :uname \"$(uuidgen)\"
      _ (print push-out)
      deploy-cmd (get-in (read-string (str "[" push-out "]")) [1 :deploy-command])
      deploy-out (sh "bash" "-c" deploy-cmd)
      _ (print deploy-out)
      status-cmd (:status-command (read-string deploy-out))]
  (println "Monitoring deployment; press Ctrl-C to exit.")
  (while true
    (print (sh "bash" "-c" status-cmd))
    (sh "sleep" "5")))

There's more where that came from if you subscribe to my newsletter.