To ensure your site benefits from the most recent features and corrections, it’s crucial to keep it updated with the latest theme version. This article will guide you through the process of establishing a GitHub workflow that will automatically update the theme version. This action will perform daily checks for any updates to the theme. If an update is detected, it will generate a PR to update your site to the most recent theme version.

Setup Github Workflow

Now, create a theme-update.yml file in the .github/workflows folder of your repository with the following content:

name: "Theme Update"

    - cron: "0 0 * * *"

    runs-on: ubuntu-latest
      - uses: actions/checkout@v4.1.1
          ref: main

      - name: Setup Node
        uses: actions/setup-node@v4
          node-version: 18

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2.6.0
          hugo-version: "latest"
          extended: true

      - name: Update hugo modules
        run: |
          # update to latest version of all modules
          hugo mod get -u

          # update the npm dependencies
          hugo mod npm pack

          # cleanup go.sum file
          hugo mod tidy          

      - name: Install node modules
        run: npm install

      - name: Build
        run: |
          # build the site
          hugo --minify
          # remove file generated by the build
          rm -rf public/          

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v5
          base: main
          title: Update theme
          labels: automerge

You’re good to go. From now on, this action will execute on a daily basis and generate a Pull Request if any updates to the theme are detected.