name: Create Jellyfin-web artifact
on:
  release:
    types: [published]
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    strategy:
      matrix:
        jellyfin-web-version: [10.9.11]
    steps:
      - uses: actions/checkout@v4
      - name: Setup Node.js environment
        uses: actions/setup-node@v4
        with:
          node-version: ">=20"
      - name: Checkout official jellyfin-web
        uses: actions/checkout@v4
        with:
          repository: jellyfin/jellyfin-web
          ref: v${{ matrix.jellyfin-web-version }}
          path: web
      - name: Apply intro skipper patch
        run: |
          cd web
          git apply ../webui.patch
      - name: Build web interface
        run: |
          cd web
          npm ci --no-audit
          npm run build:production
      - name: Upload web interface
        uses: actions/upload-artifact@v4
        with:
          name: jellyfin-web-${{ matrix.jellyfin-web-version }}+${{ github.sha }}
          path: web/dist
          if-no-files-found: error