Question

Rebuild static website on content change

I have a Strapi CMS and Gridsome static website as 2 components on App platform. Is there a way to rebuild the static website on change using Strapi’s webhooks?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 18, 2021
Accepted Answer

Hi there @stfnnklc,

It looks like that a similar question has been discussed previously here. What you could do is use the DigitalOcean API to force a rebuild for your application.

You would need to make a POST request to the /v2/apps/<app_id>/deployments route and pass a JSON document for the body. You can set the force_build option in it like so:

curl \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer TOKEN" \
    "https://api.digitalocean.com/v2/apps/<app_id>/deployments" \
    -XPOST \
    -d '{"force_build": true}'

Hope that this helps! Regards, Bobby

If someone want to use the new DO serverless functions:

function main(args) {
  const https = require('https');
  const url = 'https://api.digitalocean.com/v2/apps/fda88e43-3e89-46e1-bbac-d4c25993fda6/deployments';
  const data = JSON.stringify({"force_build": true});

  const options = {
    host: 'api.digitalocean.com',
    port: 443,
    path: '/v2/apps/<APP_ID>/deployments',
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <TOKEN>',
      'Content-Type': 'application/json',
      'Content-Length': data.length
    }
  };

  var req = https.request(options, function(res) {
    console.log("statusCode: ", res.statusCode);
    console.log("headers: ", res.headers);

    res.on('data', function(d) {
      process.stdout.write(d);
    });
  });

  req.write(data); // Write the request body
  req.end();
}

With the new DO serverless functions you could receive the Strapi webhook request and then trigger the deployment.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.