Created
June 17, 2019 17:29
-
-
Save kyptin/898ece3fd3cf9a0b5cfd4076e71abb83 to your computer and use it in GitHub Desktop.
Deploy current commit to Datomic Ions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This automates the process of using Datomic Ions to push, deploy, and wait for | |
# the deployment to finish. It works as of com.datomic/ion.dev version 0.9.229. | |
# For more info, see https://docs.datomic.com/cloud/ions/ions.html | |
set -euxo pipefail | |
status_cmd=$(clj -A:dev -m datomic.ion.dev '{:op :push}' 2>&1 | \ | |
grep -v ^Downloading | \ | |
grep -v '^(' | \ | |
clj -e ' | |
(let [in (slurp *in*) | |
_ (binding [*out* *err*] (println "\nOutput from push command:\n" in)) | |
{:keys [rev deploy-groups dependency-conflicts]} (read-string in) | |
group (first deploy-groups) | |
cmd (format "clj %s '\''{:op :deploy, :group %s, :rev \"%s\"}'\''" | |
"-A:dev -m datomic.ion.dev" group rev)] | |
(binding [*out* *err*] (println "\nAbout to execute command:\n" cmd)) | |
(println cmd))' | \ | |
bash | \ | |
clj -e ' | |
(let [in (slurp *in*) | |
_ (binding [*out* *err*] (println "\nOutput from deploy command:\n" in)) | |
{:keys [execution-arn]} (read-string in) | |
cmd (format "clj %s '\''{:op :deploy-status, :execution-arn %s}'\''" | |
"-A:dev -m datomic.ion.dev" execution-arn)] | |
(println cmd))') | |
echo "Status command: $status_cmd" | |
if [ ! -z "$status_cmd" ]; then | |
line=`echo $status_cmd | bash` | |
set +x | |
while true; do | |
if [[ $line =~ "RUNNING" ]]; then | |
echo "Deployment incomplete at $(date); sleeping 5 seconds." | |
else | |
break | |
fi | |
sleep 5 | |
line=`echo $status_cmd | bash` | |
done | |
fi | |
echo "Deployment complete at $(date). Final deployment status: ${line}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment