diff options
author | Stefan Kreutz <mail@skreutz.com> | 2020-07-06 22:40:21 +0200 |
---|---|---|
committer | Stefan Kreutz <mail@skreutz.com> | 2020-07-06 22:40:21 +0200 |
commit | 07c1d9f590e8de064e9b527c3d425eb898f7e59e (patch) | |
tree | 38307806182a481ca534e853a8ba2c3db9596a0c /deploy | |
download | blog-07c1d9f590e8de064e9b527c3d425eb898f7e59e.tar |
Add initial version
This commit adds the first published version of the website including
the first blog post, Unix Domain Socket Forwarding with OpenSSH.
Diffstat (limited to 'deploy')
-rwxr-xr-x | deploy | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -0,0 +1,41 @@ +#! /bin/sh + +# Deploy the static website. +# +# Re-generates the static website from source and asserts a clean working tree +# before uploading the website to the server. + +set -o errexit +set -o nounset + +# Git root directory +root="$( git rev-parse --show-toplevel )" + +# Source directory with a trailing slash for rsync +src="${root}/_site/" + +# Git revision +rev="$( git rev-parse --verify HEAD )" + +# ISO 8601 timestamp +now="$( date -u "+%Y-%m-%dT%H:%M:%SZ" )" + +# Archive file name +archive="./${now}_${rev}.tar.gz" + +printf "Re-generating static website from source ...\\n" +( cd "${root}" \ + && stack run -- clean >/dev/null 2>&1 \ + && stack run -- build >/dev/null 2>&1 ) + +[ -z "$( git status --porcelain )" ] || { + ( >&2 printf "error: dirty working tree\\n" ) + printf "Aborting deployment due to unstaged changes or untracked files.\\n" + exit 1 +} + +tar -czf "${archive}" "${src}" +scp "${archive}" engine.skreutz.com:www-archive/ + +rsync --rsync-path=openrsync --archive --delete --verbose \ + "${src}" "engine.skreutz.com:/var/www/htdocs/www.skreutz.com" |