From 9a221e3a122b79eb93be0da6ca6e7c783b2e7a84 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 9 Apr 2022 17:41:39 +0530 Subject: [PATCH] feat: deploy build assets in public dir on pages branch --- Makefile | 3 +++ scripts/zola.sh | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) 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