Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philhawksworth/d5b4f7ea48541a20d183eba53b1400a7 to your computer and use it in GitHub Desktop.
Save philhawksworth/d5b4f7ea48541a20d183eba53b1400a7 to your computer and use it in GitHub Desktop.
A daily scheduled function to rebuild a Netlify site with a build hook.
// npm install @netlify/functions
// to get access to scheduling function invocations
// using cron notiation or some handy aliases
const { schedule } = require("@netlify/functions");
const handler = async function(event, context) {
// Trigger a site rebuild and deploy
fetch("https://api.netlify.com/build_hooks/HOOK-ID-FROM-ADMIN", {
method: "POST"
});
return {
statusCode: 200,
};
};
exports.handler = schedule("@daily", handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment