CI/CDINTERMEDIATE

Running Playwright in GitHub Actions with Sharding & Reports

A production-ready GitHub Actions workflow for Playwright — matrix sharding, browser caching, and HTML report artifacts.

iff Solution Academy July 2, 2026 10 min read Updated July 6, 2026
Playwright GitHub Actions CI Sharding

The Minimal Workflow

.github/workflows/e2e.yml
name: E2E
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: 'npm' }
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test

Matrix Sharding for Speed

yaml
strategy:
  fail-fast: false
  matrix:
    shard: [1, 2, 3, 4]
steps:
  - run: npx playwright test --shard=${{ matrix.shard }}/4

Upload the HTML Report

yaml
- uses: actions/upload-artifact@v4
  if: always()
  with:
    name: playwright-report-${{ matrix.shard }}
    path: playwright-report
    retention-days: 14

CI Tips

  • Cache ~/.cache/ms-playwright to speed up browser installs.
  • Set retries: 2 in CI only, using process.env.CI.
  • Fail the PR on any test failure — never continue-on-error.
  • Post the HTML report URL as a PR comment for reviewers.

Get Playwright tutorials in your inbox

Weekly tips, real-world examples, and framework patterns – no spam, unsubscribe anytime.

Recommended Next Articles