name: 'Generate registry area labels'
on:
  push:
    branches:
      - main
    paths:
      - model/**
      - ./.github/workflows/generate-registry-area-labels.yml
      - ./internal/tools/scripts/generate-registry-area-labels.sh

  workflow_dispatch:

permissions:
  contents: read

jobs:
  generate-component-labels:
    permissions:
      issues: write # required for labeling PRs
    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'open-telemetry' }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

      # areas.txt is generated by the Make target generate-gh-issue-templates
      - name: Generate registry area labels
        run: |
          make generate-gh-issue-templates
          ./internal/tools/scripts/generate-registry-area-labels.sh ./internal/tools/bin/areas.txt
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
