diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 7eb1eb01e..ae28fd604 100755 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -400,52 +400,24 @@ jobs: staging-e2e: name: Staging E2E Tests runs-on: saas + container: mcr.microsoft.com/playwright:v1.45.0-jammy if: github.ref_name == 'develop' || github.ref_name == 'main' needs: deploy-staging steps: - - name: Install SSH client - shell: sh - run: | - set -eu - apt-get update -qq && apt-get install -y -qq openssh-client >/dev/null 2>&1 - echo "openssh-client installed" + - name: Checkout + uses: actions/checkout@v4 - - name: Run Playwright E2E on staging server - shell: sh + - name: Run Playwright E2E on staging + working-directory: apps/web env: - STAGING_SSH_HOST: ${{ secrets.STAGING_SSH_HOST }} - STAGING_SSH_USER: ${{ secrets.STAGING_SSH_USER }} - STAGING_SSH_KEY: ${{ secrets.STAGING_SSH_KEY }} + E2E_BASE_URL: https://staging.xiaoxiajianji.com + E2E_API_BASE: https://staging-api.xiaoxiajianji.com/api/v1 + E2E_BROWSER_CHANNEL: chromium run: | set -eu - staging_host="${STAGING_SSH_HOST:-47.98.113.167}" - staging_user="${STAGING_SSH_USER:-root}" - if [ -f /root/.ssh/xiaoxia_runtime_builder ]; then - key_path="/root/.ssh/xiaoxia_runtime_builder" - elif [ -n "${STAGING_SSH_KEY:-}" ]; then - key_path="$HOME/.ssh/id_ed25519" - printf '%s\n' "$STAGING_SSH_KEY" > "$key_path" - chmod 600 "$key_path" - else - echo "ERROR: No SSH key available" - exit 1 - fi - ssh-keyscan -H "$staging_host" >> ~/.ssh/known_hosts - - # 在业务服务器上跑 Playwright E2E(用 host 网络访问 staging 3001/8000 端口) - ssh -i "$key_path" "$staging_user@$staging_host" ' - cd /var/lib/xiaoxia-saas-staging/repo - docker run --rm \ - -e E2E_BASE_URL=http://127.0.0.1:3001 \ - -e E2E_API_BASE=http://127.0.0.1:8000/api/v1 \ - -e E2E_BROWSER_CHANNEL=chromium \ - -v "$PWD:/workspace" \ - -w /workspace/apps/web \ - --network host \ - mcr.microsoft.com/playwright:v1.45.0-jammy \ - sh -lc "npm ci && npx playwright test --reporter=line --project=chromium" - ' + npm ci + npx playwright test --reporter=line --project=chromium build-production-runtime-images: name: Build Production Runtime Images