Replace raw mirror job with ci.mirror helper
change xtlrlkutokxzqwwnmpwpokyrtxpspmkq
commit cbb2d4ee66b403c3eeb00de774eb1e6bb7292908
author Alpha Chen <alpha@kejadlen.dev>
date
parent pwotzpyp
diff --git a/.quire/ci.fnl b/.quire/ci.fnl
index 73a8ea3..da6b10c 100644
--- a/.quire/ci.fnl
+++ b/.quire/ci.fnl
@@ -1,26 +1,8 @@
-(local {: job} (require :quire.ci))
-(local mirror-url "https://github.com/kejadlen/quire.git")
+(local {: mirror} (require :quire.ci))
+
+(mirror "https://github.com/kejadlen/quire.git"
+        {:refs [:refs/heads/main]
+         :secret :github_token
+         :tag (fn [{: sha}]
+                (.. :v (os.date "!%Y-%m-%d") "-" (sha:sub 1 8)))})
 
-(job :tag-and-mirror [:quire/push]
-     (fn [{: sh : secret : jobs}]
-       (let [{: ref : sha : git-dir} (jobs :quire/push)
-             token (secret :github_token)]
-         (when (= ref :refs/heads/main)
-           (let [date (-> (sh "date --utc +%Y-%m-%d")
-                          (. :stdout)
-                          (: :gsub "\n$" ""))
-                 tag (.. :v date "-" (sha:sub 1 8))
-                 encoded (-> (sh "printf '%s' \"$T\" | base64 --wrap=0"
-                                 {:env {:T (.. "x-access-token:" token)}})
-                             (. :stdout))
-                 auth-header (.. "Authorization: Basic " encoded)
-                 git-opts {:env {:GIT_DIR git-dir}}]
-             (sh [:git :tag tag sha] git-opts)
-             (sh [:git
-                  :-c
-                  (.. :http.extraHeader= auth-header)
-                  :push
-                  :--porcelain
-                  mirror-url
-                  :refs/heads/main
-                  (.. :refs/tags/ tag)] git-opts))))))