deploy on yannesposito.com

This commit is contained in:
Yann Esposito (Yogsototh) 2021-04-18 17:40:32 +02:00
parent 7f5758cd6e
commit 4b0d89488e
Signed by untrusted user who does not match committer: yogsototh
GPG Key ID: 7B19A4C650D59646
2 changed files with 17 additions and 22 deletions

View File

@ -1,12 +1,4 @@
#!/usr/bin/env stack #!/usr/bin/env runhaskell
{- stack
--resolver lts-6.12
--install-ghc
runghc
--package turtle
--package ansi-terminal
--verbosity s
-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
import Turtle import Turtle
@ -15,6 +7,7 @@ import Prelude hiding (FilePath)
import qualified Control.Foldl as Fold import qualified Control.Foldl as Fold
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import System.Console.ANSI import System.Console.ANSI
import Turtle.Line (unsafeTextToLine)
import Control.Exception (catches,Handler(..)) import Control.Exception (catches,Handler(..))
main = mainProc `catches` [ Handler handleShellFailed main = mainProc `catches` [ Handler handleShellFailed
@ -24,12 +17,12 @@ main = mainProc `catches` [ Handler handleShellFailed
handleShellFailed :: ShellFailed -> IO () handleShellFailed :: ShellFailed -> IO ()
handleShellFailed (ShellFailed cmdLine _) = do handleShellFailed (ShellFailed cmdLine _) = do
setSGR [SetColor Foreground Dull Red] setSGR [SetColor Foreground Dull Red]
echo $ ("[FAILED]: " <> cmdLine) echo $ ("[FAILED]: " <> unsafeTextToLine cmdLine)
setSGR [Reset] setSGR [Reset]
handleProcFailed :: ProcFailed -> IO () handleProcFailed :: ProcFailed -> IO ()
handleProcFailed (ProcFailed procCommand procArgs _) = do handleProcFailed (ProcFailed procCommand procArgs _) = do
setSGR [SetColor Foreground Dull Red] setSGR [SetColor Foreground Dull Red]
echo $ ("[FAILED]: " <> procCommand <> (mconcat procArgs)) echo $ unsafeTextToLine ("[FAILED]: " <> procCommand <> (mconcat procArgs))
setSGR [Reset] setSGR [Reset]
@ -39,20 +32,20 @@ mainProc = do
-- Too bad. -- Too bad.
-- So instead, I'll check I'm in the right directory. -- So instead, I'll check I'm in the right directory.
debug "Checking directory" debug "Checking directory"
(hakylldir,pubdir) <- checkDir pubdir <- checkDir
debug "Retrieving revision number" debug "Retrieving revision number"
rev <- fold (inshell "git rev-parse --short HEAD" empty) Fold.head rev <- fold (inshell "git rev-parse --short HEAD" empty) Fold.head
debug ("Revision number retrieved: " <> fromMaybe "unknow" rev) debug ("Revision number retrieved: " <> fromMaybe "unknow" rev)
debug $ "cd " <> (format fp pubdir) debug $ unsafeTextToLine $ "cd " <> (format fp pubdir)
cd pubdir cd pubdir
pwd >>= echo . format fp pwd >>= echo . unsafeTextToLine . format fp
dshells "git init ." dshells "git init ."
dshell ("git remote add upstream " <> mainRepository) dshell ("git remote add upstream " <> mainRepository)
dshells "git fetch upstream" dshells "git fetch upstream"
dshells "git reset upstream/gh-pages" dshells "git reset upstream/gh-pages"
dshells "git add -A ." dshells "git add -A ."
echo "Commit and publish" echo "Commit and publish"
dshells ("git commit -m \"publishing at rev " <> (fromMaybe "unknow" rev) <> "\"") dshells ("git commit -m \"publishing at rev " <> lineToText (fromMaybe "unknow" rev) <> "\"")
echo "Don't `git push` this time" echo "Don't `git push` this time"
dshells "git push -q upstream HEAD:gh-pages" dshells "git push -q upstream HEAD:gh-pages"
@ -62,19 +55,19 @@ debug txt = do
setSGR [Reset] setSGR [Reset]
dshells x = do dshells x = do
debug x debug $ unsafeTextToLine x
shells x empty shells x empty
dshell x = do dshell x = do
debug x debug $ unsafeTextToLine x
shell x empty shell x empty
checkDir :: IO (FilePath,FilePath) checkDir :: IO FilePath
checkDir = do checkDir = do
toolsExists <- testdir "tools" toolsExists <- testdir "engine"
if (not toolsExists) if (not toolsExists)
then exit (ExitFailure 1) then exit (ExitFailure 1)
else return (".","content/_site") else return "_optim"
mainRepository = "git@github.com:yogsototh/yannesposito.com.git" mainRepository = "git@github.com:yogsototh/yannesposito.com.git"

View File

@ -9,6 +9,8 @@ let
protolude protolude
pkgs1909.haskellPackages.sws pkgs1909.haskellPackages.sws
stache stache
turtle
ansi-terminal
]; ];
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps; ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
in in
@ -25,8 +27,8 @@ pkgs.mkShell {
niv niv
git git
direnv direnv
# ghc ghc
# haskellPackages.shake haskellPackages.shake
tmux tmux
# for emacs dev # for emacs dev
ripgrep ripgrep