how to extract webpage from a git repo and then throw it into root of www server

computer_glamour a59960dc72 Update 'README.md' hai 2 semanas
LICENSE 6d5ae3fbbb Initial commit hai 2 semanas
README.md a59960dc72 Update 'README.md' hai 2 semanas

README.md

GOGS website sync with git repo

how to extract webpage from a git repo and then throw it into root of www server

git --git-dir=/path/to/repo.git archive HEAD | tar -x -C /destination/path

script that can be runned with crontab every 5min

It checks if the repo hash has changed from last time if yes it extracts it into a folder

GIT_DIR=/path/to/repo.git
DEST=/destination/path
STATE_FILE=/var/tmp/repo_last_commit.txt

# get current commit hash
curr=$(git --git-dir="$GIT_DIR" rev-parse HEAD) || exit 1

# read last seen commit (empty if missing)
last='' 
[ -f "$STATE_FILE" ] && last=$(cat "$STATE_FILE")

# if changed, extract and update state
if [ "$curr" != "$last" ]; then
  git --git-dir="$GIT_DIR" archive "$curr" | tar -x -C "$DEST" || exit 1
  echo "$curr" > "$STATE_FILE"
fi