netlify-build-github-actions icon indicating copy to clipboard operation
netlify-build-github-actions copied to clipboard

An example of triggering a Netlify build using Github Actions Scheduled Events

⏰ Trigger Netlify builds on a schedule using Github Actions

  1. Add a Build hook to your site using the Netlify Dashboard

    Settings > Build & Deploy > Continuous Deployment > Build hooks

  2. Create a .github/workflows/main.yml file in your Github repo, replacing YOUR_BUILD_HOOK with the build hook you just created.

    name: Trigger Netlify Build
    on:
      schedule:
        - cron: '*/15 * * * *' # every 15 mins
    jobs:
      build:
        name: Request Netlify Webhook
        runs-on: ubuntu-latest
        steps:
          - name: Curl request
            run: curl -X POST -d {} YOUR_BUILD_HOOK
    
  3. Adjust the cron settings to determine how often the build will be triggered.
    15 8 * * * would run every day at 0815
    0 0,12 * * * would run at midday and midnight every day
    crontab guru can help you generate the correct cron syntax.
    See the Github Actions Docs for more info.

  4. Open the Actions tab in you Github repo to watch the workflow complete. 🎉