Docker/obsidian-livesync/notes-autocommit.sh

16 lines
364 B
Bash
Executable File

#!/bin/sh
# Commits and pushes the LiveSync-mirrored notes repo. Run from cron.
set -eu
REPO=/home/simon/repo/notes
# Skip this run if the previous one is still going.
exec 9>/tmp/notes-autocommit.lock
flock -n 9 || exit 0
cd "$REPO"
git add -A
git diff --cached --quiet && exit 0
git commit -q -m "Autocommit $(date '+%Y-%m-%d %H:%M')"
git push -q origin main