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"
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.
Top comments (0)