Skip to content

Instantly share code, notes, and snippets.

@tough-griff
Last active January 31, 2019 16:25
Show Gist options
  • Save tough-griff/3cb387b151bfa1d405135f422f863a0a to your computer and use it in GitHub Desktop.
Save tough-griff/3cb387b151bfa1d405135f422f863a0a to your computer and use it in GitHub Desktop.
Auto-update script for github repo

Instructions

  • Save the plist file to $HOME/Library/LaunchAgents/, renamed appropriately (e.g. username.UpdateSomeRepository.plist)
  • Copy update.sh to the repository you wish to sync. Change the message if you want.
  • Replace user/machine specific variables in the plist file
    • Replace gyourick in your with your username (whoami).
    • Update the <key>Program</key> value to the path of your update.sh.
    • Change the time the script runs under <key>StartCalendarInterval</key>. Hour is in 24-hour time and uses your machine's local time.
  • Run launchctl load -w $HOME/Library/LaunchAgents/username.UpdateSomeRepository.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>gyourick.UpdateDotfiles</string>
<key>KeepAlive</key>
<false/>
<key>RunAtLoad</key>
<false/>
<key>UserName</key>
<string>gyourick</string>
<key>Program</key>
<string>/Users/gyourick/dotfiles/update.sh</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
<key>StandardOutPath</key>
<string>/Users/gyourick/Library/Logs/gyourick.UpdateDotfiles.log</string>
<key>StandardErrorPath</key>
<string>/Users/gyourick/Library/Logs/gyourick.UpdateDotfiles.log</string>
</dict>
</plist>
#!/usr/bin/env bash
cd $(dirname ${BASH_SOURCE[0]})
date -R
git add -A && git commit -m "Daily automated config update" && git push
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment