name: E2E Test

on:
  pull_request:
    branches: [ "main"]
  workflow_dispatch:

jobs:
  e2e:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Install Docker Compose
        run: |
          sudo apt install -y docker-compose

      - name: Install dependencies
        run: npm install

      - name: Install Playwright
        run: npx playwright install --with-deps

      - name: Start docker containers
        run: docker-compose up --build -d

      - name: Run E2E tests
        run: npm run e2e

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: e2e-report
          path: |
            playwright-report/
            playwright-screenshots/
