name: Renovate Hugo Modules

on: pull_request

jobs:
  renovate_hugo_modules:
    name: Renovate Hugo Modules
    if: startsWith(github.head_ref, 'renovate/hugo-modules')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Pull Request HEAD Commit
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - name: Install Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: "0.111.3"
          extended: true

      - name: Update All Hugo Modules
        run: hugo mod get -u

      - name: Tidy Hugo Modules
        run: hugo mod tidy

      - name: Display Changes
        run: git status

      - name: Commit Changes
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: Renovate Hugo Modules
          commit_author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
