bjorn / rpgdx

RPGDX
http://rpgdx.net
2 stars 3 forks source link

Separate git repo from public_html #11

Closed Poikilos closed 3 months ago

Poikilos commented 3 months ago

I've changed the server to use a git checkout, to make it easier to keep it up to date. However, now the deletion of forums/install is a local change. Do you have any suggestions for dealing with this?

-@bjorn https://github.com/bjorn/rpgdx/pull/9#issuecomment-2125645067

Poikilos commented 3 months ago

The install folder is modified, so it is necessary for if there were disaster recovery. What I did was use "rsync" from the repo to the html folder on my local machine. Maybe make that does both, something like:

deploy-www.sh

#!/bin/bash
#WWW_DATA=/var/www/html
# ^ Uncomment & change value before running this script (must *not* end in slash).
#REPO=~/git/rpgdx
# ^ Uncomment & change value before running this script (must *not* end in slash).
if [ -z "$REPO" ]; then
    echo "Error: Set REPO. See comments in this script."
    exit 1
fi
cd $REPO || exit 1
git pull || exit 1
if [ -z "$WWW_DATA" ]; then
    echo "Error: Set WWW_DATA. See comments in this script."
    exit 1
fi
rsync -rt --exclude=".*" --exclude "readme.md" --exclude "development.md" --exclude "install" ./ $WWW_DATA
# ^ slash in 1st arg (not 2nd arg) is important so this dir doesn't become a sub-subfolder in dest.
cd $WWW_DATA || exit 2
if [ -d .git ]; then
  rm -rf .git
  rm .gitignore
  rm development.md
  rm readme.md
fi
if [ -d install ]; then
  rm -rf install
fi
bjorn commented 3 months ago

@Poikilos Thanks! I've set it up very similar, making the git repository no longer "bare" and using the following post-receive hook:

#!/bin/bash
REPO="/home/private/rpgdx"
WWW_DATA="/home/public"

cd $REPO || exit 1

echo "Synchronizing website at $WWW_DATA"

rsync -rtv \
    --exclude=".*" \
        --exclude "*.md" \
    --exclude "HOSTED" \
    --exclude "TODO" \
    --exclude "rpgdx.code-workspace" \
    --exclude "sql" \
    --exclude "install" \
    ./ $WWW_DATA

echo "Website deployed!"