Skip to content

Instantly share code, notes, and snippets.

@dferber90
Last active April 27, 2022 06:56
Show Gist options
  • Save dferber90/715e9b1946c647d48582354d93612d6d to your computer and use it in GitHub Desktop.
Save dferber90/715e9b1946c647d48582354d93612d6d to your computer and use it in GitHub Desktop.
Percy on GitHub actions
# This goes into .github/workflows/percy.yml
name: Visual Regression Tests
on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v1
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-yarn-
- name: install
run: yarn
- name: build
run: yarn build
env:
CI: true
VRT: true
PRODUCTION: true
- name: test
run: yarn test:visuals
env:
CI: true
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_COMMIT: ${{ github.sha }}
# github.head_ref is only defined on pull requests
# When the type is not a PR it must be a push. We can then read
# the ref from github.event.ref, which most likely contains "refs/heads/master"
# So we would have PERCY_BRANCH: ${{ github.head_ref || github.event.ref }}
# But Percy expects just the string "master" without the /ref/heads prefix.
# That's why it has to be hardcoded. This is okay, since regular pushes are
# only happening on master and everything else must be a PR.
PERCY_BRANCH: ${{ github.head_ref || 'master' }}
PERCY_PULL_REQUEST: ${{ github.event.number }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment