Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script for automating Datomic Cloud Ion push + deploy
(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")))
Copy link

rbubke commented Jun 21, 2019

Great work. Helped me a lot. Thx.

Copy link

jacobobryant commented Jun 21, 2019

@rbubke glad to hear it! I've since adapted this into a pure Clojure version which you may be interested in. It runs a lot faster since you don't have to start up a new JVM for each command.
It can be run with:

clj -Sdeps '{:deps {trident/ion-dev {:mvn/version "0.1.7"}}
             :mvn/repos {"datomic-cloud" {:url "s3://datomic-releases-1fc2183a/maven/releases"}}}' \
    -m trident.ion-dev.deploy --help

Copy link

rbubke commented Jun 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment