name: Pull Request

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

on:
  pull_request:
    branches:
      - master
      - release*
    paths-ignore:
      - '**/*.md'

jobs:
  build:
    name: Build 🏗️
    if: ${{ always() && !cancelled() }}
    uses: ./.github/workflows/__package.yml
    with:
      commit: ${{ github.event.pull_request.head.sha }}

  quality_checks:
    name: Quality checks 👌🧪
    if: ${{ always() && !cancelled() }}
    uses: ./.github/workflows/__quality_checks.yml
    permissions: {}
    with:
      commit: ${{ github.event.pull_request.head.sha }}

  codeql:
    name: GitHub CodeQL 🔬
    if: ${{ always() && !cancelled() }}
    uses: ./.github/workflows/__codeql.yml
    permissions:
      actions: read
      contents: read
      security-events: write
    with:
      commit: ${{ github.event.pull_request.head.sha }}

  run-eslint:
    name: Run eslint suggestions
    if: ${{ github.repository == 'jellyfin/jellyfin-web' }}
    runs-on: ubuntu-latest
    
    steps:
      - name: Check out Git repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          ref: ${{ github.event.pull_request.head.sha }}
    
      - name: Setup node environment
        uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
        with:
          node-version-file: .nvmrc
          cache: npm
          check-latest: true 
    
      - name: Install Node.js dependencies
        run: npm ci --no-audit
    
      - name: Run eslint
        uses: CatChen/eslint-suggestion-action@2b07b898c0dd5a016586d22b54282199b79cd358 # v4.1.33
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
