Right up at the top of the Create deploys | Netlify Docs page, I see:
When you create a deploy manually without continuous deployment, Netlify does not run a build command.
That’s spelled out plainly enough, but I’d like to know if there’s any way around that or if there’s a possibility that this is being changed in the future. And since I don’t know all of the inner workings of Netlify, could you tell me the reasoning behind that design choice?
From my limited, outside perspective, my server telling Netlify that something changed and that the site should be rebuilt using files that I provide seems very similar to Github telling Netlify that something changed and that the site should be rebuilt using use the files on Github.
Those are my main questions. If you want some more background on what I want to build and what I’ve tried so far, I’ve included it below. But you could also just stop here!
What I’m trying to build:
I’d love to build a drag and drop site builder where the site’s React markup would be represented as a JSON object - type, props, ids, etc. Ideally, this would be something I could use to build sites for other people and manage their sites for them.
Once I hit ‘Save’ on the builder, I would like to:
-
Create a site via the Netlify API
-
Upload some files to the site, including the JSON file of markup, a generated netlify.toml file with the appropriate build and plugin declarations, and a local plugin that I write that will:
-
In the
onPreBuild
step, transform the JSON into React files and inject them into a gatsby/react-static/other static site generator template -
Run the appropriate build command as normal on Netlify to build and deploy the site
What I’ve tried:
-
Just uploading the files via the API, hoping it would trigger a build. It did not, which is in line with the docs note that manual deploys do not run a build command
-
Working around the ‘we don’t build on a manual deploy’ by trying to add a build hook and POSTing to the build hook URL after uploading the files for the deploy. The build hook was created for my site, but it does not show up in the Netlify UI nor does it run a build when I POST to it via Postman (with a 200 status)
Possible workarounds on my end:
-
Create a git repository for each site with the JSON markup and add continuous deployment for each repository. This feels like an unnecessary step in between my server and Netlify. My server would mostly be wrangling Github and using Github as a database as a way to get code on Netlify instead of working with Netlify to get code on Netlify.
-
Generate the full site
dist
folder on my server and then upload the entire thing to Netlify. This seems inefficient, since Netlify is full of super smart people who have put a ton of work into a build pipeline, and my build pipeline would be a piece of garbage in comparison. And if the entire thing needs to be built beforehand, I’m throwing a ton of bloat over the web when I could just send a small payload with all of the information required to generate the site. -
I’m open to other suggestions, if you’ve got any!
Thanks for reading this through! Again, my main questions:
- What is the reasoning behind not allowing manual deploys to run a build step?
- Is there any way for me to get manual deploys to use the build pipeline?
Matthew