name: E2E Tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      SHIPLIGHT_API_TOKEN: ${{ secrets.SHIPLIGHT_API_TOKEN }}
      SHIPLIGHT_API_URL: ${{ vars.SHIPLIGHT_API_URL }}
      SHIPLIGHT_WEB_URL: ${{ vars.SHIPLIGHT_WEB_URL }}
    steps:
      - uses: actions/checkout@v5

      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: "22"

      - name: Install dependencies
        run: npm ci

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

      - name: Run E2E tests
        run: npx shiplight test

      - name: Upload results to Shiplight
        if: always()
        env:
          SHIPLIGHT_REPORT_TO_CLOUD: "1"
        run: npx shiplight report
