简体   繁体   中英

download the source code from github to my local server

so my question is I have a local nodejs server that is running on raspberry pi.The server is working with many ports and database and all. So my requirement is that when I upload a new source code to my github I need my local server to know that new code is available and it should download it and once its done it should restart the server.

I can make my local server know that new code is available but how to download it and restart the server once the code is downloaded.

You can use GitHub Webhooks that will fire, a POST request to your server (not your main one, a different one that you need to write) each time you push new code to master branch. This server will listen to this webhook requests and pull changes and restart your main server (see node child_preocess/exec).

Alternatively you can use GitHub Actions with 2 jobs, that will fire on each push to master. First with rsync action to send your new repository files. And then a SSH action to restart your server.

Both solutions expect your server to be reachable by Github servers.

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