I host a react app on a custom domain at Netlify via github. I’d like to ask if it’s possible to automatically clone and deploy to a new sub domain by actioning a script within the app itself?
Hi, @1111. Yes, it is hypothetically possible to do this. However, if and how to actually do this depend on numerous details about how you plan to implement this. For example, when you say:
what exactly does “actioning” mean? In other words, where do you want that script to be run?
Will you run the script on your local system? Do you want to use GitHub actions? Do you want to run code in the end user’s browser to trigger the deploy? Will the script be run as a Function?
All of those are possible. Not all of them are good ideas (for example, you probably don’t want people visiting your website triggering builds) but they can all be done in some way. However, each of them would likely be done in different ways so knowing how you intend to run the script will be an important part of answering.
Luke thanks. At least it’s theoretically possible. Actually I do want a user to trigger a new build I think. I’m looking for the simplest way of triggering a new build of a react template stored in github, under a new sub domain hosted on netlify. If you could give me some pointers that would be excellent
Hi, @1111. As far as pointers, you can see our API documentation here:
There are also the two support guides below:
Do you want the user to create a new site under your existing team? If so, you could make Functions that have an API key from Netlify embedded in them and then have the site call those functions to create the new site
If you plan to take that route, then the following support guide about embedding API keys will be helpful:
If there are other questions, please let us know.
Thank you Luke for your detailed reply. Much appreciated. Will get back and let you know how we are doing with this. Lots to discover with Netlify!