Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can commits/pushes to github be automated?

Tags:

github

jekyll

I've moved a site to a Jekyll / GitHub Pages setup and have an iOS-based markdown editor that syncs to dropbox. Currently I'm investigating ways to bridge the gap and have files created on the go automatically committed and pushed to the GitHub repo but unsure where to start. Is anything like this possible?

(I am not experienced in using Automator on OSX but it seems like it might be an option, though I can't guarantee that a machine will be awake all the time)

like image 864
Don H Avatar asked Jul 25 '12 22:07

Don H


Video Answer


1 Answers

Using cron should do the trick. Note that you'll need to have key-based authentication set up for git so you're not prompted a password on push.

(Note that I've used these tools in Linux, but they should work in OS X as well.)

Create your script somewhere

#!/bin/sh
cd /path/to/git/repo
git commit -a -m "Automated commit message." # commit all changes
git push

Make the schript executable
chmod + x script.sh

Run crontab -e to edit your cron file, and add 0 * * * * /path/to/script.sh to execute the script once per hour.

This also assumes that this will be the only committer. If anyone else pushes to the repo from elsewhere, you'll have to merge those changes to this clone before this script will push successfully again.

You could also check out Flashbake!

like image 54
Curtis Avatar answered Sep 30 '22 03:09

Curtis