name: Lint proto files

on:
  push:
    paths:
      - 'proto/**/*.proto'
      - '.github/workflows/buf-lint.yml'

permissions:
  contents: read

jobs:
  buf-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Check for .proto files
        id: proto-check
        run: |
          if find proto -name '*.proto' -type f 2>/dev/null | grep -q .; then
            echo "has_proto=true" >> $GITHUB_OUTPUT
          else
            echo "has_proto=false" >> $GITHUB_OUTPUT
            echo "No .proto files found — skipping buf-lint (node is ZAP-native by default; protobuf is opt-in)."
          fi
      - uses: bufbuild/buf-setup-action@v1
        if: steps.proto-check.outputs.has_proto == 'true'
        with:
          github_token: ${{ github.token }}
          version: "1.47.2"
      - uses: bufbuild/buf-lint-action@v1
        if: steps.proto-check.outputs.has_proto == 'true'
        with:
          input: "proto"
