I have a lambda function that sends a POST request to a Netlify build hook, which triggers a new build on Netlify. My question is, can this flow work locally with Netlify Dev / CLI? I can run a function at my local url (e.g. http://localhost:8888/.netlify/functions/myFunc), but it seems like there’s no way to locally trigger a build hook? Is that correct?
Yup - we have not implemented any of that "trigger a build by " functionality, so far, in netlify dev. You can hit the production build hook, on our service, by accessing its URL from your locally-running function - but that will trigger a build HERE, not on your local
Of course you could mock up a hook (in a function you create) that you hit instead, that does something like run a shell command to run your build. Might help to understand what your larger goal is (e.g. “I need to trigger builds every 10 minutes”) rather than your proposed solution (“I’ll be using a function to trigger a build via buildhook”), to see if we can come up with a more relevant workaround, since I don’t quite understand that bigger picture
Hi @fool, thanks for the response. The bigger picture is, I have a headless CMS (prismic.io) that only sends certain data via a GET request, my understanding is build hooks cannot access GET data, only POST? So I’m having to use a function to receive the GET data and hit a build hook with the same data as POST to rebuild a static site based on said data.
ah, wow, yeah, I guess if your tool isn’t using POSTs we wouldn’t be able to let it trigger a build hook, so that workflow though a bit convoluted is the best way to do it mostly-with-netlify (vs putting something like zapier.com in the chain).
At least in your function you can also massage the data into whatever format you need - one “gotcha” with build hooks is that if your post data is massive (>~90k as some contentful setups send at times; not heard the same of prismic but I suppose it is possible!), you could make sure NOT to forward that much since your build will immediately fail if you pipe in a huge webhook body.