From 0c69ef6214a9e69424e1fd481a78e91990782be0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 8 Dec 2016 22:55:04 +0100 Subject: Update git-deploy script --- provider/posts/blog/git-deploy.md | 47 ++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'provider/posts/blog') diff --git a/provider/posts/blog/git-deploy.md b/provider/posts/blog/git-deploy.md index 92d94fe..443f8d8 100644 --- a/provider/posts/blog/git-deploy.md +++ b/provider/posts/blog/git-deploy.md @@ -19,6 +19,7 @@ handled by `post-update`: ~~~{.sh} #!/usr/bin/env zsh + touchedMaster=false for ref ($@); do @@ -31,19 +32,43 @@ done $touchedMaster || exit 0 { - tmpDir=$(mktemp -d) - delTmpDir() { - cd / - rm -rf ${tmpDir} - } - - trap delTmpDir EXIT + checkoutDir=/srv/git/checkouts/$(basename $(pwd)) + + print ${checkoutDir} + + mkdir -p $(dirname ${checkoutDir}) + + unset GIT_DIR - git clone --branch master --depth 1 --single-branch file://$(pwd) ${tmpDir} + if [[ -d ${checkoutDir} ]]; then + git -C ${checkoutDir} fetch origin + else + rm -rf ${checkoutDir} + git clone --depth 1 file://$(pwd) ${checkoutDir} + fi - cd ${tmpDir} - umask 0022 - nix-shell --run "dirty-haskell build && dirty-haskell deploy" + git -C ${checkoutDir} checkout -f origin/master + + { + umask 0022 + cd ${checkoutDir} + + script=$(mktemp) + delScript() { + rm -v ${script} + } + trap delScript EXIT + chmod +x ${script} + + >${script} <&1 | stdbuf -o 0 tr '\r' '\n' | logger --id=$$ -p daemon.info -t dirty-haskell ~~~ -- cgit v1.2.3