3

I have a static site (Gatsby) that builts with GitHub Actions and uses data that is organized in Contentful. The content changes frequently in a row (like 10 changes within 10 minutes) and this currently results in the page being recreated multiple times in a row for no reason.

Is there any simple mechanism (in GitHub or Contentful) that can be used handle this issue?

If not, what might be useful approaches to handle this problem?

K. D.
  • 4,041
  • 9
  • 48
  • 72

2 Answers2

2

Contentful DevRel here.

Depending on the needs, I see people implementing static regeneration in different ways.

Rebuild after triggered web hooks

Define and send auto-save or publish webhooks from Contentful to your build server to trigger a regeneration. As you described this can lead to a lot of rebuilds depending on how busy the users in your Contentful space are.

Add a build trigger to the Contentful UI

Contentful's App framework lets you extend the contentful interface with custom UI. For e.g. you could set up this custom webhook app built by the community that allows you to trigger builds on a button click.

For Netlify, there's an integration available. Unfortunately, as of now for other build pipelines (Vercel, Travis, GitHub Action), it would need to be something custom.


For your case, I recommend having a look at a custom build trigger in the UI.

stefan judis
  • 3,416
  • 14
  • 22
  • Thank you very much. The second approach looks nice. I think it would be great to have such an App by default. The only variable in there is the URL that users must be able to change. – K. D. Nov 24 '20 at 13:59
  • Agree. Let's see if we can make that a thing in the future. :) Until then, you could install this app and define your URL. :) – stefan judis Nov 24 '20 at 14:14
  • Just in case anyone is looking for something quick and easy as I had the exact same problem; https://www.producthunt.com/posts/hookbox – Liam Martens Nov 05 '21 at 21:49
0

This can be addressed on the build pipeline side.

For example, Workflow Run Debounce action for GitHub.

Another approach is to have a middleware like https://hookbox.freighter.studio/ to debounce the webhook requests in between the Headless CMS and the Build Pipeline. Probably there are open-source and self-hosted alternatives.

AKd
  • 501
  • 4
  • 17