Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push files to GitHub from NodeJS server

I have a NodeJS server which is generating a server-side JS code into a separate folder on the server and then serves it to the user as a .zip file. I would like to be able to take this code and push it to a GitHub repository the user would specify (or even better- create a new brunch and push it to the branch). I was checking GitHub API but I could not find an endpoint, which would describe this situation. I also checked one node module, but the same story- no information about if this is possible (and how) or not.

My question is- Is it possible to take a folder on a server and push it to a GitHub repo (if all the credentials and keys are known) programatically and if so, can anyone please direct me to some resources? I tried to find something but nothing was relevant.

Thank you, T.

like image 445
user1377911 Avatar asked Jan 21 '15 18:01

user1377911


Video Answer


1 Answers

I've just found these two libraries, that can help you to push your files to git from Node.js:

  • git-js is a lightweight wrapper around installed git binary
  • nodegit is a standalone Git client implementation in Node.js

Just use the provided API programmatically to commit and push files. You could create a separate branch if you want and tag your commits.

like image 122
Slava Fomin II Avatar answered Oct 09 '22 03:10

Slava Fomin II