Deploy notification with Gatsby Cloud

I’m not sure if I’m doing it correctly but I needed a way to notify DatoCMS if the status is successful or not.

Let’s say I’ve just created/updated/deleted records and I wanted the changes to reflect in production.
Because of the Build Trigger I made I am able to do it. I used Gatsby Clouds Build Webhook as the trigger URL, which works. The changes in the record are also reflected on production.

The problem is, even if the changes are now in production; the build and deployment succeeded; the building process is still on going. I needed to find a way to tell DatoCMS if the build is successful or not. I don’t know where to use the example in the 2nd step. Right now, I had to check the page/s if the changes reflected before I abort the building process which isn’t ideal. Since my client is going to use this tool.

I hosted the site on netlify, but the deployment is triggered through gatsby cloud. I hope that made sense.

Hello @humphrey.litan welcome to Community! :slight_smile:

First of all, I’m not sure if you want to use the build trigger for what you want to achieve. The build trigger is meant as a “manually triggered webhook”. But from what you are saying maybe you want to use the webhooks instead? (https://www.datocms.com/docs/general-concepts/webhooks)

Can you please check if this issue: https://github.com/datocms/gatsby-source-datocms/issues/120#issuecomment-665558144 helps you?

Let me know if that works for you, we need to add documentation for that still, sorry.

Instead have you seen this guide by any chance: https://www.gatsbyjs.com/cloud/docs/dato-cms/getting-started/ ? Not sure if relevant for your use case though.

Hello @mat_jack1, thank you for the quick reply. You’re probably right. I just tried using on webhook and it worked. Does it usually take a long time for it to be deployed the first time? The build in gatsby cloud takes a few seconds, but the deployment to netlify takes 5 minutes. Although as I kept on publishing records (i set publish/unpublish as my trigger), the deployment time seemed to have diminished from 5 minutes to 1 to 15 seconds to less than 10 seconds. Is that normal?

I tried using webhooks awhile ago, but the changes weren’t reflecting on the production site. Right now it did. Though I don’t know what made it happen…

Anyway, thank you so much. It’s my first time to try a headless CMS and Webhooks.

Last question, is there any way for the user to know if the changes have been published on the site on DatoCMS alone?

Ah, I think the deployment notification could be done on Netlify in their Deploy Notifications by providing a webhook url

hey @humphrey.litan glad that with the webhooks it works :slight_smile:

The build times are normal, from what you are saying, they depend on the caching mechanisms of Gatsby and Netlify, you should investigate a bit more on these ends.

Maybe to show if a deployment finished on Netlify you can use the “build trigger” to trigger a build there and see the result.

So you can use Gatsby Cloud for previews with webhooks and use build triggers for manual deploys on Netlify. Have a look here: https://www.datocms.com/docs/general-concepts/deployment for more details on deploying with build triggers.

1 Like

unfortunately not for the single change, but with build triggers you can know if the entire site was published :slight_smile:

1 Like

Thank you so much, @mat_jack1. You’ve been very helpful. :blush:

1 Like