Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev guideRecipesAPI ReferenceChangelog
Dev guideRecipesUser GuidesNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Use case: Gatsby deployment

Example use case of automating Gatsby builds based on content changes, providing a streamlined development workflow.

A Gatsby Build Webhook lets you programmatically trigger builds of your Gatsby projects. Registering this webhook with the Optimizely Graph endpoint allows you to automate builds when specific events occur, such as content updates or data source changes. You can then test content modifications using the Optimizely Content Management System (CMS).

Create a Gatsby Build Webhook

To create a Gatsby Build Webhook:

  1. Go to Site Settings > General > Webhook in the Gatsby Cloud dashboard.

  2. Copy the Builds Webhook URL. You will need it in the following webhook registration section.

Register the webhook with Optimizely Graph

  1. Use a tool or library of your choice (such as cURL, Postman, or an HTTP client library) to make a POST request to https://cg.optimizely.com/api/webhooks to register the webhook.
  2. Use either Basic or HMAC authentication in the request.
  3. Include the required parameters in the request payload, including the Gatsby Builds Webhook URL obtained in the previous section and any additional configuration required by the Optimizely Graph webhook API.
  4. Send the request and await the response from the Optimizely Graph webhook API.
  5. After registration, the API responds with the details of the registered webhook, including its unique identifier.

Test content modification with CMS

To test the integration between the Gatsby Build Webhook and the Optimizely Graph webhook API using the Optimizely CMS Dashboard:

  1. Access the CMS Dashboard for your project.

  2. Modify a content item that should trigger the Gatsby build process, such as updating content or changing metadata.

  3. Save the changes in the CMS Dashboard. This triggers a webhook event and notifies the Optimizely Graph webhook endpoint.

  4. Monitor the logs or other relevant output to ensure the webhook event is received and processed.

  5. Confirm that the Gatsby build process starts and completes successfully in the Gatsby Cloud dashboard.

Ensure you handle potential errors or exceptions during the webhook event processing and build process. Also, see the documentation for Gatsby Build Webhooks, the Optimizely Graph webhook API, and Optimizely CMS for information on monitoring and troubleshooting.