name: Check license headers
on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - rust/**
      - python/**
      - nodejs/**
      - java/**
      - .github/workflows/license-header-check.yml

permissions:
  contents: read

jobs:
  check-licenses:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v6
      - name: Install license-header-checker
        working-directory: /tmp
        run: |
            curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash
            mv /tmp/bin/license-header-checker /usr/local/bin/
      - name: Check license headers (rust)
        run: license-header-checker -a -v ./rust/license_header.txt ./ rs && [[ -z `git status -s` ]]
      - name: Check license headers (python)
        run: license-header-checker -a -v ./python/license_header.txt python py && [[ -z `git status -s` ]]
      - name: Check license headers (typescript)
        run: license-header-checker -a -v ./nodejs/license_header.txt nodejs ts && [[ -z `git status -s` ]]
      - name: Check license headers (java)
        run: license-header-checker -a -v ./nodejs/license_header.txt java java && [[ -z `git status -s` ]]
