Schedule recurring tasks

If you want to schedule recurring tasks, one option is to use GitHub Actions. In the following example, we will create an action that publishes an index every hour.

In your GitHub repo, create a new action and enter the following definition:

name: Publish Index
on:
  workflow_dispatch:
  schedule:
    - cron: "55 * * * *"

jobs:
  publish-index:
    runs-on: ubuntu-latest
    steps:
    - name: Invoke admin
      uses: fjogeleit/http-request-action@v1
      with:
        url: 'https://admin.hlx.page/index/org/site/main/query-index.json'
        method: 'POST'
        timeout: 30000
        customHeaders: '{"Authorization":"token ${{ secrets.ADMIN_API_KEY }}"}'

Every hour, 5 minutes before the hour, the action is invoked and will publish the index for project org/site. We add an authorization header containing an admin API key that we create ourselves and store in the repository’s action secrets as ADMIN_API_KEY.