aboutsummaryrefslogtreecommitdiff
path: root/bin/hook
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hook')
-rwxr-xr-xbin/hook/deploy.rb19
1 files changed, 18 insertions, 1 deletions
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