By stfnnklc
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?
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!
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
With the new DO serverless functions you could receive the Strapi webhook request and then trigger the deployment.
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();
}
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.