Can you deploy existing build to another site?

I’m trying to setup the following workflow and am unsure if it is currently doable with Netlify.

  1. I have a staging site that automatically builds my staging branch and can be accessed at staging.example.com
  2. I have a pre-production preview site that automatically builds my master branch and can be accessed at production.example.com
  3. I have a production site and I want to take an existing build from my pre-production site and deploy it on my production site.

I don’t think I’m in a position right now where I can use Netlify DNS. So what I would like to do is have these 2 sites that automatically build a branch, and a third site where I can deploy existing builds.

Figuring out if it is possible to deploy an existing build from another site is where I’m currently blocked.

hey there. We’ve been a little short staffed this week, but we’ll get you an answer as soon as we can. thanks for your patience!

Hello @NAllred91 and thanks so much for your patience!

Your workflow as described isn’t easily possible today - you’d have to download a copy of your deploy and reupload it. It’s not easy to download a copy of the deploy directly and reliably without making quite a few API calls, and dealing with rate limits, and you basically wouldn’t want to do that in our CI. Maybe if you ran your own server and you didn’t mind a deploy taking Quite A While Even Though No Build Was Needed, you could do it, but there’s a better way!

Instead of using 3 sites, use one, and configure it like this:

  1. use our branch subdomains feature as explained here - this serves staging.example.com for you: [Support Guide] How to use Netlify’s branch deploy feature without Netlify DNS
  2. set the site’s production branch to a nonexistent one. I can do this for you if you have trouble doing it in our UI (it will be moderately complex to do this; I can talk you through it if you really want to but I can flip a single switch to change your production branchname to NOTACTUALLYUSED or something like that with 0 effort).
  3. Then, you can see your master branch as “master.example.com” using that same branch subdomain functionality
  4. Use our API (see details on usage to publish (at your production URL), one of the “pre-prod” builds. You’ll use this API call: Netlify API documentation . Note you can do this to ANY deploy from ANY branch on a site - doesn’t have to be the production branch, doesn’t even have to be a branch build - could be a PR build or something.

This isn’t what you asked for - but you came with a solution, so hopefully my alternative solution, achievable today, solves your problem ok :slight_smile: If not, let me know why not and maybe I can help work around that!

Thanks!

I admit this desired workflow is mostly unnecessary thanks to package-lock.json. And since rollbacks are easy and quick I’m probably not going to spend much more time worrying about this.

Overall, it just makes me a little uncomfortable doing a build and sending it straight into production without doing some manual verification on the built assets. It just feels more “correct” to create a build, put it on a staging server to be validated (manual testing, internal reviews, etc…), and then move that same exact asset into production.

In practice though, this will probably never be something that bites me. Would be a nice feature though!