-
Notifications
You must be signed in to change notification settings - Fork 1
/
check.hs
57 lines (43 loc) · 1.16 KB
/
check.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ExtendedDefaultRules #-}
module Main where
import Shelly
import qualified Data.Text as T
import Control.Monad
default (T.Text)
git_ :: T.Text -> [T.Text] -> Sh ()
git_ = command1_ "git" []
git' :: T.Text -> [T.Text] -> Sh T.Text
git' = command1 "git" []
exmsg :: T.Text
exmsg = "Already up-to-date"
len :: Int
len = T.length exmsg
main :: IO ()
main = shelly $ do
git_ "checkout" ["master"]
msg <- git' "pull" []
if T.take len msg == exmsg then return () else deploy
deploy :: Sh ()
deploy = do
-- run_ "cabal" ["run", "pfad", "rebuild"]
run_ "stack" ["exec", "--", "pfad", "rebuild"]
git_ "checkout" ["gh-pages"]
files <- lsT "_site"
forM_ files $ \file -> do
run_ "cp" ["-r", file, "."]
files <- findWhen test_f "_site"
forM_ files $ \file -> do
t <- toTextWarn file
git_ "add" [T.drop 6 t]
files <- findWhen test_f "css"
forM_ files $ \file -> do
t <- toTextWarn file
git_ "add" [t]
files <- findWhen test_f "js"
forM_ files $ \file -> do
t <- toTextWarn file
git_ "add" [t]
git_ "commit" ["-m", "update"]
git_ "push" []
`finally_sh` git_ "checkout" ["master"]