Skip to content

Instantly share code, notes, and snippets.

@samedhi
Created May 6, 2019 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samedhi/44c33488daed9cac8a44d49f56e6d8fe to your computer and use it in GitHub Desktop.
Save samedhi/44c33488daed9cac8a44d49f56e6d8fe to your computer and use it in GitHub Desktop.
(ns io.github.samedhi.push
(:require
[clojure.string :as string]
[planck.shell :as shell]))
(def input-blog "/Users/stephencagle/blog")
(def output-blog "/Users/stephencagle/samedhi.github.io/")
(def now (:out (shell/sh "date" "-u" "+%FT%T%z")))
(defn sh [& args]
(let [{:keys [exit] :as m} (apply shell/sh args)]
(when (not= exit 0)
(throw
(ex-info (str "Exit code " exit " `" (string/join " " args) "` "(pr-str m)) m)))
m))
(shell/with-sh-dir
input-blog
(sh "cp" "-rf" "resources/public/" output-blog) )
(shell/with-sh-dir
output-blog
(sh "git" "pull")
(when (-> (sh "git" "diff" "--exit-code") :exit (not= 0))
(sh "git" "add" ".")
(sh "git" "commit" "-m" now)
(sh "git" "push")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment