Skip to content

Instantly share code, notes, and snippets.

@dgrebb
Last active January 17, 2024 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgrebb/34ba1d5683ee668e6c7282013a4065b9 to your computer and use it in GitHub Desktop.
Save dgrebb/34ba1d5683ee668e6c7282013a4065b9 to your computer and use it in GitHub Desktop.
Install and Cache Playwright from `package.json` Dependencies | GitHub Composite Action
name: "Install and Cache Playwright"
description: "Sets up a cache and/or installs Playwright and its browser binaries."
author: dgrebb
inputs:
WORKSPACE_ROOT:
description: "The workspace root."
required: true
runs:
using: "composite"
steps:
- name: Get installed Playwright version
shell: bash
working-directory: ${{ inputs.WORKSPACE_ROOT }}
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(cat package.json | jq -r '.dependencies.playwright' || 'latest')" >> $GITHUB_ENV
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- shell: bash
working-directory: ${{ inputs.WORKSPACE_ROOT }}
run: npm ci
- shell: bash
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.WORKSPACE_ROOT }}
run: npx playwright install --with-deps
- shell: bash
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.WORKSPACE_ROOT }}
run: npx playwright install-deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment