34 lines
857 B
Bash
34 lines
857 B
Bash
#!/bin/bash
|
|
|
|
# The production directory
|
|
TARGET="/var/www/friends.of.mineral.town"
|
|
# Local (to server) git repository
|
|
GIT_DIR="~/mineral.town.git"
|
|
# A temporary directory for deployment
|
|
TEMP="~/work"
|
|
# Name of production branch
|
|
BRANCH="main"
|
|
|
|
while read oldrev newrev ref
|
|
do
|
|
# only checking out the deployment branch
|
|
if [ "$ref" = "refs/heads/$BRANCH" ];
|
|
then
|
|
mkdir $TEMP
|
|
|
|
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
|
|
git --work-tree=$TEMP --git-dir=$GIT_DIR checkout -f $BRANCH
|
|
|
|
# build blog
|
|
cd $TEMP/blog
|
|
hugo -D
|
|
|
|
# Replace production directory with updated project files
|
|
cd ~
|
|
rm -rf $TARGET
|
|
mv $TEMP/ $TARGET/
|
|
else
|
|
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
|
|
fi
|
|
done
|