简体   繁体   中英

Is there a way to let Rails push an internal repository to Github while its hosted?

Assume that I have a Rails project. I have published it on a server like Heroku. Think of it as a small app that have to update a git repository (a separate repository in its public folder). Is there a way to achieve this?

For example...

Think that i have some markdown files in my public folder. My rails app will give me an interface to edit these files. When the editing is over, I need to push these files to a git repository. Only that folder through a script in the Rails app.

You can either shell out to git:

Dir.chdir('/path/to/git/tree') do
  system = "git commit -m'Updated by rails' -- #{name_of_file_to_commit}"
  # Check $?, and do some appropriate error handling if it's != 0
end

Or you can use one of the several ruby Gems for interfacing with git. I am not familiar enough with them to recommend one; in any case, any recommendation will soon be out of date. It's best to do your own search, find candidate gems, and try them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM