Skip to content

Update Snapshots

Update Snapshots #2

name: Update Snapshots
on:
workflow_dispatch:
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push
contents: write
env:
NODEJS_VERSION: 20
jobs:
update_snapshots:
name: Update Snapshots
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup NodeJS SDK ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: ${{ env.NODEJS_VERSION }}
- name: Yarn Install
run: yarn install
# caching playwright browsers, see https://github.com/microsoft/playwright/issues/7249
- name: Store Playwright Version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Browsers for Playwright Version
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright Browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: yarn playwright install --with-deps
- name: Install Playwright Dependencies
if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
run: yarn playwright install-deps
- name: Update Snapshots
run: yarn test --grep snapshot --update-snapshots --reporter=list
- name: Commit and Push Snapshots
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update Playwright Snapshots
file_pattern: "tests/visual/*.png"