Allow passthrough repos using bind mounts, work in temp directory, log to screen and file
This commit is contained in:
@@ -8,18 +8,35 @@ set -e -v
|
||||
date
|
||||
|
||||
# check if initial git run
|
||||
if [ ! -d /repo ]; then
|
||||
# yes - repo needs to be cloned
|
||||
git clone --recurse-submodules $REPO_URL /repo
|
||||
if [ "$REPO_URL" == "" ]; then
|
||||
# no repo URL set.
|
||||
# most likely the repo is passed through as volume
|
||||
# do not pull, treat the repo as-is
|
||||
true
|
||||
else
|
||||
# no - pull existing repo
|
||||
cd /repo && git pull --recurse-submodules
|
||||
# repo URL set
|
||||
if [ ! -d /repo ]; then
|
||||
# repo needs to be cloned
|
||||
git clone --recurse-submodules $REPO_URL /repo
|
||||
else
|
||||
# no - pull existing repo
|
||||
cd /repo && git pull --recurse-submodules
|
||||
fi
|
||||
fi
|
||||
|
||||
# create temporary working directory
|
||||
tmpdir=$(mktemp --directory)
|
||||
# copy over into temporary directory
|
||||
cp -r /repo/* $tmpdir
|
||||
|
||||
# build and copy over
|
||||
cd /repo && \
|
||||
cd $tmpdir && \
|
||||
hugo && \
|
||||
rm -rf /usr/share/nginx/html/* && \
|
||||
cp -R /repo/public/* /usr/share/nginx/html
|
||||
cp -R $tmpdir/public/* /usr/share/nginx/html && \
|
||||
chown nginx:nginx -R /usr/share/nginx/html
|
||||
|
||||
} 2>&1 > /var/log/blogker-pull-n-build.log
|
||||
# cleanup
|
||||
rm -rf $tmpdir
|
||||
|
||||
} 2>&1 | tee /var/log/blogker-pull-n-build.log
|
||||
|
||||
Reference in New Issue
Block a user