summaryrefslogtreecommitdiff
path: root/provider/posts
diff options
context:
space:
mode:
Diffstat (limited to 'provider/posts')
-rw-r--r--provider/posts/blog/git-deploy.md47
1 files changed, 36 insertions, 11 deletions
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`:
19~~~{.sh} 19~~~{.sh}
20#!/usr/bin/env zsh 20#!/usr/bin/env zsh
21 21
22
22touchedMaster=false 23touchedMaster=false
23 24
24for ref ($@); do 25for ref ($@); do
@@ -31,19 +32,43 @@ done
31$touchedMaster || exit 0 32$touchedMaster || exit 0
32 33
33{ 34{
34 tmpDir=$(mktemp -d) 35 checkoutDir=/srv/git/checkouts/$(basename $(pwd))
35 delTmpDir() { 36
36 cd / 37 print ${checkoutDir}
37 rm -rf ${tmpDir} 38
38 } 39 mkdir -p $(dirname ${checkoutDir})
39 40
40 trap delTmpDir EXIT 41 unset GIT_DIR
41 42
42 git clone --branch master --depth 1 --single-branch file://$(pwd) ${tmpDir} 43 if [[ -d ${checkoutDir} ]]; then
44 git -C ${checkoutDir} fetch origin
45 else
46 rm -rf ${checkoutDir}
47 git clone --depth 1 file://$(pwd) ${checkoutDir}
48 fi
43 49
44 cd ${tmpDir} 50 git -C ${checkoutDir} checkout -f origin/master
45 umask 0022 51
46 nix-shell --run "dirty-haskell build && dirty-haskell deploy" 52 {
53 umask 0022
54 cd ${checkoutDir}
55
56 script=$(mktemp)
57 delScript() {
58 rm -v ${script}
59 }
60 trap delScript EXIT
61 chmod +x ${script}
62
63 >${script} <<EOF
64#! /usr/bin/env nix-shell
65#! nix-shell -i sh ${checkoutDir}/shell.nix
66
67dirty-haskell build && dirty-haskell deploy
68EOF
69
70 ${script}
71 }
47} 2>&1 | stdbuf -o 0 tr '\r' '\n' | logger --id=$$ -p daemon.info -t dirty-haskell 72} 2>&1 | stdbuf -o 0 tr '\r' '\n' | logger --id=$$ -p daemon.info -t dirty-haskell
48~~~ 73~~~
49 74