Stephan van Rooij

Software architect with a passion for home automation.


Daily rebuild github pages

Published Jun 27, 2020

Today I switched to personal website for my new personal page on Github. It’s a pretty nice template to generate a static page with the use of Jekyll, at build time it loads some details from github (like my repositories). This means that the page will only show the data of the last time it was build.

Github actions to the rescue

You can however trigger a Github Page build by calling some github endpoint. So let’s do that on a regular interval.

  1. Setup a personal access token with public_repo.
  2. Save the token as secret in the repository as GH_TOKEN.
  3. Add a workflow file to trigger the build.
# File: .github/workflows/rebuild.yml
name: Rebuild

    - cron:  '0 6 * * *' # Runs every day at 6am

    runs-on: ubuntu-latest
      - name: Call GitHub pages build endpoint
        run: |
          curl --fail --request POST \
            --url${{ github.repository }}/pages/builds \
            --header "Authorization: Bearer $GH_TOKEN"
          # Create a token at
          # since you cannot trigger a new build with the regular token.
          GH_TOKEN: ${{ secrets.GH_TOKEN }}

You’ll need an extra personal access token because you cannot trigger an action from an action, this could potentially lead to an endless loop. In all other cases you shouldn’t need to create a new personal access token, since you already get the ${{ secrets.GITHUB_TOKEN }} inside each Github actions run.