diff --git a/Makefile b/Makefile index 790c01e..5919d95 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ default: ## Build the website clean: ## Clean build assets ./scripts/zola.sh clean +deploy: ## Deploy build + ./scripts/zola.sh deploy pages public + env: ## Download build dependencies and setup dev environement ./scripts/zola.sh install diff --git a/scripts/zola.sh b/scripts/zola.sh index 4b3d0b4..229d2ac 100755 --- a/scripts/zola.sh +++ b/scripts/zola.sh @@ -36,6 +36,7 @@ USAGE: OPTIONS: b build build website c clean clean dependencies and build artifacts + d deploy deploy build to branch h help print this help menu i install install build dependencies u url make urls relative @@ -88,6 +89,19 @@ clean() { echo "[*] Workspace cleaned" } +# $1: branch name +# $2: directory containing build assets +deploy() { + cd $PROJECT_ROOT + tmp_dir=$(mktemp -d) + cp -r $2/* $tmp_dir + git checkout --orphan $1 + git rm -rf . + /bin/rm -rf * + cp -r $tmp_dir/* . + git add --all && git commit -m "new deploy: $(date --iso-8601=seconds)" +} + check_arg $1 download @@ -97,6 +111,11 @@ then elif match_arg $1 'c' 'clean' then clean +elif match_arg $1 'd' 'deploy' +then + check_arg $2 + check_arg $3 + deploy $2 $3 elif match_arg $1 'b' 'build' then build