name: License Header Updater

on:
  schedule:
    - cron: '0 0 1 1 *'  # Every January 1st
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write
  
jobs:
  update-headers:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Get current year
        id: date
        run: echo "year=$(date +'%Y')" >> "$GITHUB_OUTPUT"
      - name: Install Go 1.25
        uses: actions/setup-go@v6
        with:
          go-version: '1.25'
      - name: Run license header update (go run)
        run: go run ./tools/license_headers/main.go
      - name: Create PR
        uses: peter-evans/create-pull-request@v8
        with:
          commit-message: "chore: update license headers for ${{ steps.date.outputs.year }}"
          title: "Update license headers for ${{ steps.date.outputs.year }}"
          body: "Automatically updated license headers for year ${{ steps.date.outputs.year }}."
          labels: "chore"
