name: "Data: Sync labels"
run-name: Sync Labels from YML on ${{ github.event_name }}

on:
  workflow_dispatch:
  push:
    branches:
      - "main"
    paths:
      - ".github/labels.yml"
  pull_request:
    paths:
      - ".github/labels.yml"

permissions:
  contents: read

jobs:
  labeler:
    permissions:
      contents: read # for actions/labeler to determine modified files
      pull-requests: write # for actions/labeler to add labels to PRs
      issues: write # for actions/labeler to add labels to issues

    if: ${{ github.repository_owner == 'Armbian' }}
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Run Labeler
        uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d # v6.0.0
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          yaml-file: .github/labels.yml
          dry-run: ${{ github.event_name == 'pull_request' }}
          exclude: |
            Maintenance*