I have a simple express.js-powered API running on an ubuntu server with pm2. The server.js
and the other files are in /var/www/node/api/
.
On this server, at /srv/git-repos/api.git/
is my git repository, where I commit new changes from my local machine.
The Question is, is it possible, that every time I commit new changes to the server, it recognizes this, and clones my repository to let's say /var/www/node/api-dev/
(which will then be available at dev.example.com, this could be made possible with nginx, so there is no problem) and restarts my pm2 instance with pm2 restart api
.
Because then I would test, if my changes work on the server, and when they do, I just can copy the content of /var/www/node/api-dev
to /var/www/node/api
manually.
Or is there another, better workflow? It's just a small API on which I will make many changes because I want to develop it for the needs of my frontend.
Thanks for your answers and suggestions, I hope it's understandable what I want to archive.