name: PR suggestions

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.id || github.run_id }}
  cancel-in-progress: true

on:
  pull_request_target:
    branches: [ master, release* ]

jobs:
  run-eslint:
    name: Run eslint suggestions
    runs-on: ubuntu-latest

    steps:
      - name: Check out Git repository
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - name: Setup node environment
        uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
        with:
          node-version: 20
          check-latest: true
          cache: npm

      - name: Install Node.js dependencies
        run: npm ci --no-audit

      - name: Run eslint
        if: ${{ github.repository == 'jellyfin/jellyfin-web' }}
        uses: CatChen/eslint-suggestion-action@09aa3e557bafa4bebe3e026d8808bffff08e67a9 # v4.1.6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
