Created
March 2, 2023 14:05
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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