Created
May 6, 2019 15:29
-
-
Save samedhi/44c33488daed9cac8a44d49f56e6d8fe to your computer and use it in GitHub Desktop.
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
(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