POST-Deploying multiple jekyll sites at once

This commit is contained in:
2018-12-07 09:48:48 -05:00
parent f3e3ff8ee8
commit 75296acbac
3 changed files with 69 additions and 16 deletions

View File

@@ -1,27 +1,22 @@
#!/usr/bin/env bash
# post-receive hook to build and deploy jekyll sites
"/var/lib/git/gogs/gogs" hook --config='/var/lib/git/gogs/conf/app.ini' post-receive
GIT_REPO="$(pwd)"
TMP_GIT_CLONE="/tmp/${GIT_REPO##*/}"
GIT_DIR="$(pwd)"
TMP_GIT_DIR="/tmp/${GIT_DIR##*/}"
if [ ! -d "{$TMP_GIT_CLONE}" ]; then
git clone "${GIT_REPO}" "$TMP_GIT_CLONE"
cd "${TMP_GIT_CLONE}"
if [ ! -d "${TMP_GIT_DIR}" ]; then
git clone "${GIT_DIR}" "${TMP_GIT_DIR}"
cd "${TMP_GIT_DIR}"
else
cd "${TMP_GIT_CLONE}"
# avoid breaking the build when force pushing
cd "${TMP_GIT_DIR}"
unset GIT_DIR
git fetch --all
git reset --hard origin/master
git pull
fi
pushd "${TMP_GIT_CLONE}"
for site in *.*/; do
[[ ! -d /var/www/${site} ]] && mkdir -p /var/www/${site} && chgrp -R /var/www/${site} && chmod g+s /var/www/${site}
[ ! -d /var/www/${site} ] && mkdir -p /var/www/${site} && chgrp -R /var/www/${site} && chmod g+s /var/www/${site}
pushd ${site}
bundle install --deployment
bundle exec jekyll build --destination /var/www/${site}