coreos-home-server/service/hugo/container/config/deploy.sh
Alex Palaistras a99e97abfe hugo: Switch to webhook-based builder
This commit switches Hugo to a webhook-based building process, with
support for Github, Gitlab, and Gitea hooks (including local versions of
Gitea) initially. In addition, Hugo-based sites are now intended to be
served under a single volume, with ingress configuration pointing to
sub-paths into the volume.

Documentation for webhook setup and NGINX proxy configuration is still
underway, and will be filled in later.
2022-10-28 17:52:05 +01:00

32 lines
765 B
Bash
Executable File

#!/bin/sh
set -eu
GIT_REPO_URL="$1"
GIT_BRANCH="$2"
if test -z "$GIT_REPO_URL"; then
echo "Repository URL not defined, aborting..." >&2
exit 1
elif test -z "$GIT_BRANCH"; then
echo "Branch name not defined, aborting..." >&2
exit 1
fi
GIT_DIR_NAME=$(basename "$GIT_REPO_URL" .git)
GIT_SSH_COMMAND="ssh -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null"
for t in rsa ecdsa ed25519; do
GIT_SSH_COMMAND="$GIT_SSH_COMMAND -i /etc/ssh/keys/ssh_host_${t}_key"
done
export GIT_SSH_COMMAND
if test -d "$GIT_DIR_NAME"; then
cd "$GIT_DIR_NAME"
git fetch origin "$GIT_BRANCH"
else
git clone --branch "$GIT_BRANCH" -- "$GIT_REPO_URL" "$GIT_DIR_NAME"
cd "$GIT_DIR_NAME"
fi
hugo --verbose --destination "/build/${GIT_DIR_NAME}"