aboutsummaryrefslogtreecommitdiff
path: root/bin/hook
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hook')
-rwxr-xr-xbin/hook/deploy.rb19
-rw-r--r--bin/hook/etc/webhook.conf4
-rw-r--r--bin/hook/etc/webhook.service6
3 files changed, 21 insertions, 8 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
diff --git a/bin/hook/etc/webhook.conf b/bin/hook/etc/webhook.conf
index 34c2929..69c5842 100644
--- a/bin/hook/etc/webhook.conf
+++ b/bin/hook/etc/webhook.conf
@@ -9,10 +9,6 @@
"pass-environment-to-command": [{
"source": "string",
- "envname": "DEPLOY_HTDOCS_PATH",
- "name": "/data/www/example.com/htdocs"
- }, {
- "source": "string",
"envname": "DEPLOY_REPO_DIR",
"name": "/data/www/example.com/git"
}, {
diff --git a/bin/hook/etc/webhook.service b/bin/hook/etc/webhook.service
index 20cd6bb..006fa35 100644
--- a/bin/hook/etc/webhook.service
+++ b/bin/hook/etc/webhook.service
@@ -4,11 +4,11 @@ After=network.target
ConditionPathExists=/etc/webhook.conf
[Service]
-# debian/ubuntu version of webhook is comically old, so i'm using the static
-# binary from the github releases page
+# use -verbose to enable debugging
# ExecStart=/usr/local/bin/webhook -port 9000 -hooks /etc/webhook.conf -urlprefix '' -verbose
ExecStart=/usr/local/bin/webhook -port 9000 -hooks /etc/webhook.conf -urlprefix ''
-RunAs=webhook
+
+User=webhook
[Install]
WantedBy=multi-user.target