From f212d2ab11519cc04bb6be3def3d41d9298ce9d5 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Mon, 29 Sep 2025 16:59:03 +0200 Subject: [PATCH] Document setting Docker image version dynamically (JS) Signed-off-by: Karl Horky --- docs/src/ci.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/src/ci.md b/docs/src/ci.md index a6fa5bc44dc04..3e320ea805416 100644 --- a/docs/src/ci.md +++ b/docs/src/ci.md @@ -301,6 +301,49 @@ jobs: run: dotnet test ``` +#### Via Containers (dynamic) +* langs: js + +Setting the version of the container dynamically can be performed by retrieving the version of Playwright in a previous job. For example, if you install an exact version of Playwright, then it can be retrieved from `package.json`: + +```yml js title=".github/workflows/playwright.yml" +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + resolve-playwright-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps['resolve-playwright-version'].outputs.version }} + steps: + - uses: actions/checkout@v5 + - name: resolve-playwright-version + id: resolve-playwright-version + run: | + version="$(yq -r '.devDependencies["@playwright/test"] // ""' package.json)" + test -n "$version" || { echo "No @playwright/test version found in package.json"; exit 1; } + echo "version=$version" >> "$GITHUB_OUTPUT" + playwright: + name: 'Playwright Tests' + runs-on: ubuntu-latest + needs: resolve-playwright-version + container: + image: mcr.microsoft.com/playwright:v${{ needs['resolve-playwright-version'].outputs.version }}-noble + options: --user 1001 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Run your tests + run: npx playwright test +``` + #### On deployment This will start the tests after a [GitHub Deployment](https://developer.github.com/v3/repos/deployments/) went into the `success` state.