From 07ae6c3b7a4af1a8ea08fbe5d511e4486d242676 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 18 May 2025 07:59:17 -0400 Subject: bin/hook/deploy.rb: add DEPLOY_BASE_URL env var --- bin/hook/deploy.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/hook/deploy.rb b/bin/hook/deploy.rb index e7fcc1f..839b454 100755 --- a/bin/hook/deploy.rb +++ b/bin/hook/deploy.rb @@ -26,6 +26,9 @@ # timestamp. # * `DEPLOY_BUILD_CACHE_SIZE`: Optional, defaults to 5 if unspecified. # Number of old site builds to keep in the builds directory. +# * `DEPLOY_BASE_URL`: Optional, defaults to `baseURL` from +# `config.toml` if unspecified. Used to override the base URL for +# onion service deployment. # # load libraries @@ -54,6 +57,11 @@ NUM_SECONDS = ENV.fetch('DEPLOY_SKEW_THRESHOLD', '300').to_i # number of site builds to keep in builds directory BUILD_CACHE_SIZE = ENV.fetch('DEPLOY_BUILD_CACHE_SIZE', '5').to_i +# base URL: optional, defaults to baseURL from config.toml if +# unspecified. used to override the base URL for onion service +# deployment. +BASE_URL = ENV.fetch('DEPLOY_BASE_URL', '') + # command paths (optional) FLOCK = ENV.fetch('DEPLOY_FLOCK_PATH', '/usr/bin/flock') GIT = ENV.fetch('DEPLOY_GIT_PATH', '/usr/bin/git') @@ -121,9 +129,18 @@ pull_time = timed do run(FLOCK, SRC_DIR, GIT, 'pull', '--rebase') end +# build hugo command +hugo_cmd = if BASE_URL.length > 0 + # hugo command with custom base URL + [HUGO, '--minify', '-b', BASE_URL, '-d', DST_DIR] +else + # default hugo command + [HUGO, '--minify', '-d', DST_DIR] +end + # build site hugo_time = timed do - run(HUGO, '--minify', '-d', DST_DIR) + run(*hugo_cmd) end # update htdocs symlink -- cgit v1.2.3