How to deploy a ZIP or WAR equivalent (built locally via npm)? I use NPM to build my web project, and it does so nicely to a little ZIP file. Keeps everything nice and light, and I can easily keep bloat down.

My current process is to use an FTP client (Win SCP), to upload the ZIP file, and then I have a little deploy.sh script that simply removes the old site, and unzips the new site to the same folder.

I want to be able to build this and deploy it all in one but cannot seem to find the answers. I'm not really sure where to start. I know I could move the build process to the server (git pull, and run the npm command there) but I would rather always have full visibility of the build locally before deployment (ie. could have one script to build, and another to deploy - so yes it technically is a manual deployment, but only manual in the sense that it is triggered).

If this is posted in the wrong place, please advise - any help greatly appreciated!
There are now two possible solutions: One NPM only one, and a clean one.

First the NPM One (where im not quite sure what exactly will work):

I just googled "npm deployment" and found 3 different Plugins which do exactly that what you want ( 1, 2, 3) and there are many more. Which now you suits you best, will be your choice.



Now the cleaner one (because we are in the DevOps Stackexchange ;) ):

Use a Dedicated Service (self-hosted or provided) to build and deploy your application.
This way you will just commit your sourcecode into the VCS and the build system will build your Artifact. Then you deploy it through there via it's possibility for it.

As Example i used Atlassian Bamboo quite often for that. 


I commited my code
Bamboo gets a Trigger to build
Bamboo run the Build with the Tests
Bamboo create the Artifact
now you had the Choice to automatically deploy the Artifact or wait for a manuell Button press inside the UI


if automatically it will start a Deploy Task
else on Button Press

The Deploy Task is the configuration how it will be Deployed.


in your case: copy the ZIP, extract it, run the deployment.sh



One thing beside that all. One thing i would never do is to build ON the Live system. Sourcecode on the Live Server (even Javascript one, which is most of the time minified) is a big attack window. Beside that you could get many weird behavior due weird things that the different systems do inside the building of the artifact (like different dependencies or things like that)