dnes: trigger auto-sync to konzdat on each entry via post-commit hook
This commit is contained in:
@@ -44,6 +44,16 @@ cmd_done() {
|
|||||||
echo "- [$time_now] $text" >> "$JOURNAL_FILE"
|
echo "- [$time_now] $text" >> "$JOURNAL_FILE"
|
||||||
echo "Logged to journal: [$time_now] $text"
|
echo "Logged to journal: [$time_now] $text"
|
||||||
|
|
||||||
|
# Git checkpoint to trigger post-commit hook for Konzdat update
|
||||||
|
(
|
||||||
|
cd "$PLAN_DIR"
|
||||||
|
git add "$JOURNAL_FILE" 2>/dev/null || true
|
||||||
|
if ! git diff-index --quiet HEAD -- 2>/dev/null; then
|
||||||
|
git commit -m "dnes: $text" >/dev/null 2>&1 || true
|
||||||
|
git push origin main >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
) &
|
||||||
|
|
||||||
# Trigger Syncthing rescan so peers receive the entry immediately
|
# Trigger Syncthing rescan so peers receive the entry immediately
|
||||||
local api_key
|
local api_key
|
||||||
api_key=$(grep -oPm1 "(?<=<apikey>)[^<]+" "$HOME/.config/syncthing/config.xml" 2>/dev/null || true)
|
api_key=$(grep -oPm1 "(?<=<apikey>)[^<]+" "$HOME/.config/syncthing/config.xml" 2>/dev/null || true)
|
||||||
|
|||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# dnes-konzdat-sync: Automatically rebuilds and deploys Konzdat whenever ~/src/dnes updates
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
LOCK_FILE="/tmp/dnes-konzdat-sync.lock"
|
||||||
|
exec 201>"$LOCK_FILE"
|
||||||
|
if ! flock -n 201; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
KONZDAT_DIR="$HOME/src/konzdat"
|
||||||
|
SAMIZDAT_BIN="$KONZDAT_DIR/bin/samizdat"
|
||||||
|
|
||||||
|
if [ ! -x "$SAMIZDAT_BIN" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
WEEK_NUM=$(date +%-V)
|
||||||
|
ISSUE_CODE="W$WEEK_NUM"
|
||||||
|
|
||||||
|
echo "[dnes-konzdat-sync] Updating Konzdat ($ISSUE_CODE) from latest dnes entries..."
|
||||||
|
|
||||||
|
cd "$KONZDAT_DIR"
|
||||||
|
"$SAMIZDAT_BIN" build "$ISSUE_CODE" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# Commit and push to boxC if there are changes
|
||||||
|
git add -A >/dev/null 2>&1 || true
|
||||||
|
if ! git diff-index --quiet HEAD -- 2>/dev/null; then
|
||||||
|
NOW_STR=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
git commit -m "dnes-sync($ISSUE_CODE): auto-update from dnes journal [$NOW_STR]" >/dev/null 2>&1 || true
|
||||||
|
git push origin main >/dev/null 2>&1 || true
|
||||||
|
echo "[dnes-konzdat-sync] Successfully synchronized and deployed to http://pešek.com/konzdat/"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user