Files
strshipos-config/auto-commit.sh
T
2026-10-07 17:37:52 +00:00

34 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Watch /opt/strshipos for changes and auto-commit+push to Gitea
REPO="/opt/strshipos"
DEBOUNCE=10 # seconds to wait after last change before committing
cd "$REPO"
inotifywait -m -r -e close_write,create,delete,move \
--exclude '(\.git|data/|/logs/)' \
"$REPO" 2>/dev/null | while read -r dir event file; do
# Reset debounce timer
touch /tmp/strshipos-pending-commit
# Wait for quiet period
(
sleep $DEBOUNCE
# Only proceed if we're still the latest trigger
if [ -f /tmp/strshipos-pending-commit ]; then
rm -f /tmp/strshipos-pending-commit
cd "$REPO"
git add docker-compose.yml logo.svg favicon.svg favicon16.png favicon144.png \
xwiki-org/cssVariablesInit.min.css xwiki-com/cssVariablesInit.min.css .gitignore
if ! git diff --cached --quiet; then
git -c user.name="Robert James" -c user.email="rajames440@gmail.com" \
commit -m "auto: backup config changes $(date '+%Y-%m-%d %H:%M:%S')"
git push origin master
git push starshipos master
fi
fi
) &
done