name: Automatic Offset Generation
on:
  workflow_dispatch:

  schedule:
    - cron: '0 0 * * *'

jobs:
  updateOffsets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Setup Go
        uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
        with:
          go-version: "~1.23.1"
          check-latest: true
          cache-dependency-path: "**/go.sum"

      - name: Update offsets
        run: make offsets

      - name: Create pull request
        uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7
        with:
          commit-message: Update generated offsets
          branch: automated/generated-offsets
          delete-branch: true
          title: '[auto] Update generated offsets'
          body: 'This is an automated PR to update the generated Go field offsets.'
