Is it possible to deploy on Github Pages after editing DatoCMS content with a webhook?

254 Views Asked by At

I'm facing a problem with my website. I setup a little website on Github Pages. The website is made with Gatsby, that query information at build time from DatoCMS.

Now, I followed Gatsby guide and made a script in the package.json to make me deploy it:

"deploy": "gatsby build && gh-pages -d public"

And everything works very good! After running yarn deploy, Gatsby creates the build and publish it on my Github repository in the gh-pages branch, then it goes live on the Github pages website. The problem is that I don't want to run this command everytime I edit something on DatoCMS. What I would really like is that whenever I make and publish some changes on DatoCMS, a webhook runs and deploy it for me.

I was not able to find any guide or tutorial for this specific architecture and I wouldn't like to switch to Netlify or something else.

Do you guys know how to help me? Would be really great!

Thank you in advance.

1

There are 1 best solutions below

0
On

This kind of action (trigger something when a file is created/updated/deleted in the CMS) is known as webhook. DatoCMS provides a list of CI/CD tools to create an easy webhook integration with but unfortunately there's no GitHub integration.

However, you can still create a custom webhook to trigger a GitHub action that builds your site. The idea is to trigger a custom webhook that triggers the GitHub action that deploys your site updated.

There's not much information about the integration you've done, actions, trials, etc so it's difficult to guess the next step. As far as I know, DatoCMS provides a bunch of repositories, libraries and functionalities to listen for data changes: