Scheduling builds and deploys with Netlify

It’s not a very exciting feature and probably would not look as glorious on a roadmap. Yeat, it would make my life with Netlify easier…

I’d really love to have an ability to rebuild sites every X hours.

2 Likes

Hi @skatkov! This is a fun idea, thanks for sharing.

In the meantime, have you looked into using Zapier to automate Netlify deploys? You can set up a Zap to POST to the Netlify webhook at a certain time to get this done. Here’s a good write-up about it: https://flaviocopes.com/netlify-auto-deploy/

1 Like

fantastic resource, @lesliecdubs! @skatkov, can you say a bit more about why you would want to trigger a rebuild every x hours? Maybe if we know more we can suggest more workarounds.

Yeah, tried it. But paying ~15$/m for ability to rebuild website every hour with Zapier seems like too much (I don’t use Zapier for anything else) :slight_smile:

I wrote a simple cron service that does POST requests to rebuild my website.

2 Likes

Until Netlify has their own scheduler, https://www.easycron.com works really well and easy to setup. The free plan would easily allow for every couple hours.

Just in case anyone is interested, here is how easy a job is to setup.


then make it a POST method

Get the build hook from your site settings by enabling build hooks under “Build & Deploy”
https://app.netlify.com/sites/your-site-name/settings/deploys#build-hooks

4 Likes

I would love the ability to configure individual Netlify functions to run as Cron jobs

1 Like

@skatkov

Another cron alternative, if you want to build every hour for free, you can use IFTTT Date & Time to trigger the webhook

2 Likes

We have an open request to add scheduled deploys and functions (cron tasks), I’ve noted in that more people are asking for it. https://webtask.io/ is a popular option, but they aren’t accepting new signups right now. We use Zapier internally. Thanks for that suggestion @Jinksi .

2 Likes

Just to provide another solution to this, it is easy to use GitHub Actions to schedule builds.

You only need to add 1 file to your GitHub repo: .github/workflows/main.yml

# .github/workflows/main.yml

name: Trigger Netlify Build
on:
  schedule:
    # Run at 0815 daily
    - cron: '15 8 * * *'
jobs:
  build:
    name: Request Netlify Webhook
    runs-on: ubuntu-latest
    steps:
      - name: Curl request
        run: curl -X POST -d {} YOUR_BUILD_HOOK

Replace YOUR_BUILD_HOOK with your Netlify Build hook url.
You can use crontab.guru to easily generate your cron schedule.
A cron schedule of 0 */3 * * * would run every third hour, to answer the original question :point_up:

I wrote a blog post about this and created an example GitHub repo with this workflow if anyone is interested!

6 Likes