Triggering a build of an Antora site when changes are merged into the main branch ensures that builds occur regularly but not excessively frequently, and that they are only triggered by a trusted user (a repo owner). This approach works well with the workflow detailed in Update and deployment workflow.

As with scheduled builds, this technique makes use of a GitHub workflow to trigger a buildhook on Netlify. However, in this case the workflow runs whenever a user merges changes back into the repo to which the workflow is attached.

This procedure assumes that you have already created a buildhook in Netlify for the playbook project. For instructions on how to do so, see Configuring scheduled builds of an Antora project on Netlify.

Note
In this case the workflow is added to the content repo but the buildhook is created for the playbook repo because you need to trigger the build to use the playbook. If your site uses multiple content repos then you would need to repeat this procedure for each one.
  1. In the root of Antora content repo, create a .github/workflows/ folder.

  2. In the folder create a YAML file, such as onmerge.yml with the following content:

    onmerge.yml
    # .github/workflows/onmerge.yml
    
    name: Trigger build of site on merge
    on:
      pull_request:
        types:
          - closed
    
    jobs:
      if_merged:
        if: github.event.pull_request.merged == true
        runs-on: ubuntu-latest
        steps:
          - name: Curl request
            run: curl -X POST -d {} <your_build_hook>

    This is based on the workflow detailed in Running your workflow when a pull request merges.

  3. Push the changes to the content project to the GitHub repo.

    Note
    If you need to merge the changes back into the main branch, this should immediately trigger the workflow.

To monitor the workflow in GitHub:

  1. Select the content repo to which you added the workflow.

  2. Click Actions:

    GitHub workflows
  3. Click the relevant workflow link.