A common approach to updating a doc site is to build the site on a regular automated schedule, for example, daily at midnight. Netlify itself has recently introduced scheduled functions but it’s still a beta feature. Eric Jinks in Schedule your Netlify build with GitHub Actions has detailed an alternative method that involves creating a buildhook in Netlify and then adding it to a GitHub workflow.
The assumption is that you have already created an Antora playbook project for the site and have set up continuous deployment on Netlify, as described in Configuring continuous deployment of an Antora project on Netlify.
To create the buildhook:
-
In Netlify, select the relevant site and open Site settings.
-
From the left menu, click Build & deploy.
-
Click Add buildhook.
-
Provide a name for the webhook. For example,
Trigger <my-site> build
. -
Specify the branch to build.
-
Click Save.
-
Copy the buildhook.
To add a workflow in GitHub:
-
In the playbook project, create a
/.github/workflows
folder. -
Create a
main.yaml
file with the following content:main.yml# .github/workflows/main.yml name: Trigger Netlify Build on: schedule: # Run daily at midnight UTC - cron: '0 0 * * *' jobs: build: name: Request Netlify Webhook runs-on: ubuntu-latest steps: - name: Curl request run: curl -X POST -d {} <your_build_hook>
-
Push the changes to the playbook project to the GitHub repo.
This creates a workflow that runs at the scheduled time. When run, a CURL request containing the buildhook is sent to Netlify, triggering the build of the site.
To monitor the workflow in GitHub:
-
Select the content repo to which you added the workflow.
-
Click Actions:
-
Click the relevant workflow link.