name: License checker

on:
  push:
    branches:
    - main
    - "forks/*"
  pull_request:
    branches:
    - main
    - "v*.*.*-rc"
  merge_group:
    types: [checks_requested]
jobs:
  license-header-check:
    runs-on: ubuntu-latest
    name: license-header-check
    steps:
    - uses: actions/checkout@v5
      with:
        fetch-depth: 0
        # For pull_request, `GITHUB_SHA` contains a implicit merge commit we want to avoid
        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    - uses: taiki-e/install-action@v2
      with:
        tool: hawkeye@6.3
    - name: Check License Header
      run: |
        hawkeye check || {
          echo "::error::License header check failed."
          echo "Note: the copyright year is now required to match the file's creation date."
          echo "Hint: rebase latest main, then auto-fix:"
          echo "  git fetch origin main && git rebase origin/main"
          echo "  ./risedev fix-license-header"
          exit 1
        }
