name: Check building and linting

on:
  push:
    branches: [ "**" ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ "**" ]

jobs:
  eslint:
    name: Run ESLint
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: read
    steps:
      - name: Set up NodeJS LTS
        uses: actions/setup-node@v6
        with:
          node-version: 'lts/*'
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install pnpm
        run: npm install -g pnpm
      - name: Set pnpm store-dir path
        run: mkdir -p ~/.pnpm-store && pnpm config set store-dir ~/.pnpm-store
      - name: Install dependencies
        run: pnpm install --no-lockfile
      - name: Run ESLint
        run: npm run lint
  build:
    name: Build the project
    runs-on: ubuntu-latest
    strategy:
      matrix:
        build-script: [ build:stable, build:dev ]
    permissions:
      contents: read
    steps:
      - name: Set up NodeJS LTS
        uses: actions/setup-node@v6
        with:
          node-version: 'lts/*'
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install pnpm
        run: npm install -g pnpm
      - name: Set pnpm store-dir path
        run: mkdir -p ~/.pnpm-store && pnpm config set store-dir ~/.pnpm-store
      - name: Install dependencies
        run: pnpm install --no-lockfile
      - name: Build the project (${{ matrix.build-script }})
        run: npm run ${{ matrix.build-script }}
    