Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

karlhorky/repro-dynamic-playwright-container-image

Repository files navigation

Repro for Dynamic Playwright Container Image in GitHub Actions

Reproduction of reading the Playwright version in package.json and using it to set a dynamic version of the Playwright Docker container image in GitHub Actions:

  • Playwright version set in package.json (@playwright/test version in devDependencies)
  • GitHub Actions workflow .github/workflows/ci-container.yml which reads this version and runs tests in a container with two jobs:
    • resolve-playwright-version: Read exact version of @playwright/test from package.json and set it as output for the ci job
    • ci: Uses the resolved Playwright version in the jobs.<job_id>.container.image expression to run tests in a container using an image version matching the Playwright version

If you don't use an exact version of @playwright/test in package.json, then try either of these approaches:

  1. Retrieving the version from your package manager's lockfile (package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock, etc.)
  2. Installing all packages and retrieving the version from node_modules/@playwright/test/package.json

Why

Playwright docs mention two ways of installing Playwright browsers in CI:

  1. playwright install --with-deps
  2. Via Docker container with Microsoft's official image

Installing Playwright browsers with playwright install --with-deps can lead to long installation times (can be multiple minutes to install dependencies):

  • Install dependencies: 2m24s
  • Total: 2m42s

Screenshot 2025-09-29 at 15 37 27

Running Playwright via container (using the official Microsoft Docker image) is faster:

  • Initialize Docker container: 25s
  • Total: 50s

Screenshot 2025-09-29 at 15 38 10

Screenshot 2025-09-29 at 15 38 02

However, the Docker container approach hardcodes the Playwright version in a new place in the codebase - the GitHub Actions workflow files - requiring effort or automation to keep the Playwright versions in sync in both package.json and the GitHub Actions workflow files. There is a high chance of these versions getting out of sync as Playwright is upgraded.

This reproduction treats the version in package.json as the single source of truth and uses it to dynamically set the Docker image version in the GitHub Actions workflow.

Releases

No releases published

Packages

No packages published