Can commits/pushes to github be automated?

こ雲淡風輕ζ 提交于 2019-12-21 05:10:11

问题


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)


回答1:


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!



来源:https://stackoverflow.com/questions/11659713/can-commits-pushes-to-github-be-automated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!