name: Make Doc

on:
  schedule:
    - cron: '22 10 * * 0'

permissions:
  contents: read

jobs:
  fix:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2

      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c  # v6.4.0
        with:
          go-version-file: .go-version

      - name: Update Docs
        run: |
          bash -x -e ./.github/fixup_file_mtime.sh
          make -f Makefile.doc

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1  # v8.1.1
        with:
          commit-message: 'auto make -f Makefile.doc'
          title: 'Update generated documentation'
          body: 'Automated doc generation via `make -f Makefile.doc`'
          branch: bot/make-doc
          committer: 'coredns[bot] <bot@coredns.io>'
          author: 'coredns[bot] <bot@coredns.io>'
          signoff: true
