Skip to content

Instantly share code, notes, and snippets.

@andreaso
Created December 3, 2024 08:56
Show Gist options
  • Save andreaso/ab5033681869312f1aa12ac0c2b3fe3f to your computer and use it in GitHub Desktop.
Save andreaso/ab5033681869312f1aa12ac0c2b3fe3f to your computer and use it in GitHub Desktop.
Auto-push notes git repository
#!/bin/bash
set -o errexit
set -o nounset
cd /home/andreas/notes
[ -n "$(git status --porcelain)" ] || exit 0
git add .
git commit --no-gpg-sign -m "auto-commit"
GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -i /home/andreas/.ssh/gh_notes_ed25519" git push
# ~/.config/systemd/user/gh-notes-sync.path
[Unit]
Description=Trigger pushes of the ~/notes git repository
[Path]
PathChanged=/home/andreas/notes
Unit=gh-notes-sync.service
[Install]
WantedBy=default.target
# ~/.config/systemd/user/gh-notes-sync.service
[Unit]
Description=Pushes the ~/notes git repository
[Service]
Type=oneshot
ExecStart=/home/andreas/.local/libexec/gh-notes-sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment