DEV Community

Dan Croak
Dan Croak

Posted on • Originally published at dancroak.com

1 2

Schedule Netlify Builds with GitHub Actions

I use a custom static site generator to publish my blog. It automatically deploys to Netlify when I merge new articles into my Git repository's main branch.

To support a "scheduled article" feature, I have configured a GitHub Actions scheduled workflow:

name: daily publish

on:
  schedule:
    - cron: "0 0 * * *" # every day at midnight UTC

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Trigger Netlify build
        shell: bash
        env:
          NETLIFY_BUILD_HOOK: ${{ secrets.NETLIFY_BUILD_HOOK }}
        run: curl -X POST -d {} "$NETLIFY_BUILD_HOOK"
Enter fullscreen mode Exit fullscreen mode

Every day at midnight UTC, GitHub runs the workflow, deploying the site using a Netlify build hook. The build hook is a URL which I've stored as a GitHub encrypted secret.

When there are articles whose scheduled date matches the new UTC date, they are automatically published by this workflow.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs