Last active
April 2, 2017 13:55
-
-
Save Merovex/597c68e5ce6f72870c891ab7d50ee5d9 to your computer and use it in GitHub Desktop.
Auto Commit Git repo to GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
File.read("/PATH-TO/.auto-commit").split("\n").each do |dir| | |
Dir.chdir(dir) | |
next if `find . -newer .last-mod`.split("\n").empty? # No change to file system | |
puts "### #{Time.new.strftime("%Y-%m-%d %H:%M:%S")} (#{dir}) ###" | |
`git pull origin $(git symbolic-ref HEAD | cut -d'/' -f3)` | |
`git add . -A` | |
puts `git commit -am "Auto-commit: #{Time.new.strftime("%Y-%m-%d %H:%M:%S")}"` | |
puts `git push origin $(git symbolic-ref HEAD | cut -d'/' -f3)` if (ARGV[0] == 'push') ? true : false | |
`touch .last-mod` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have it so that Root's .ssh config points to my GitHub credentials