Deprecated GitHub Actions
Covered in this doc
- Integrating Percy with GitHub actions
percy/exec-action
docspercy/storybook-action
docspercy/snapshot-action
docs
Configuring environment variables
Keep your Percy token secret
Anyone with access to your token can add builds to your project, though they cannot read data.
Start by adding the PERCY_TOKEN
to your repos secrets. PERCY_TOKEN
is your project-specific, write-only API token. It can be found in your Percy project settings and add it to your GitHub project secrets.
In your GitHub project's settings, go to Settings > Secrets
Then set PERCY_TOKEN
to the write-only token from your Percy project. This token can be found in each Percy project's settings.

Now you can run your tests with Percy (typically percy exec -- [test command]
) and send builds to Percy from CI.
Needed with @percy/agent
If you're currently using
@percy/agent
(and haven't migrated to the new CLI), you will need to use one of these actions below.
exec-action
Checkout the action on GitHub
In the GitHub Marketplace
The Percy exec-action
should be used with any Percy SDK that uses percy exec
. This action acts as a wrapper around the percy exec
CLI command, so all you need to provide is the CLI command you use to launch your tests.
SDK setup required
Make sure you have setup one of the Percy's SDKs before getting started with the GitHub
exec-action
Quick start
To use the Percy exec GitHub action you will need to add a new step to your actions config using the percy/exec-action
action. exec-action
has one required input: the command to run your tests. You will also need to set your PERCY_TOKEN
in your GitHub projects settings.
Below is a sample config that runs Cypress with Percy. If you don't have an existing GitHub workflow file, you could place this example in <project_root>/.github/workflows/ci.yml
:
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install
run: yarn
- name: Percy Test
uses: percy/[email protected]
with:
command: "cypress run"
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install
run: yarn
- name: Percy Test
uses: percy/[email protected]
with:
command: "cypress run"
custom-command: './tests/run-tests.sh'
exec-flags: "-t 150 -h cdn.example.com"
verbose: true
silence: false
passthrough: false
working-directory: "./client"
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
Inputs
command
- Your test suites CLI commandcustom-command
- Run your own shell commandexec-flags
- Flags to pass to thepercy exec
command. See our CLI for the possible flags to pass.working-directory
(default:./
) - The directory for the commands to execute insilence
- Silence the logging from Percyverbose
- Verbose debug logging from Percypassthrough
- Set Percy env vars, but do not execute commands
storybook-action
Checkout the action on GitHub
In the GitHub Marketplace
SDK setup required
Make sure you have setup the Percy Storybook SDK before getting started with the GitHub
storybook-action
The Percy storybook-action
should be used with only the Percy Storybook SDK.
Quick start
To use the Percy exec GitHub action you will need to add a new step to your actions config using the percy/storybook-action
action. Using the default settings, you can just use the action directly. You will also need to set your PERCY_TOKEN
in your GitHub projects settings.
This is a sample config using the default setup. If you don't have an existing GitHub workflow file, you could place this example in <project_root>/.github/workflows/ci.yml
:
name: CI
on: [push, pull_request]
jobs:
default:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install
run: yarn
- name: Percy Test
uses: percy/[email protected]
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
name: CI
on: [push, pull_request]
jobs:
default:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install
run: yarn
- name: Percy Test
uses: percy/[email protected]
with:
percy-flags: "--widths=320,1280"
storybook-flags: "-c /configs/.storybook"
working-directory: "./example-storybook"
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
Custom commands
This is a setup that passes a custom command, which allows for any configuration:
name: CI
on: [push, pull_request]
jobs:
custom_command:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install
run: yarn
- name: Percy Test
uses: percy/[email protected]
with:
custom-command: 'yarn storybook:percy'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
Inputs
storybook-flags
- Flags to pass to thebuild-storybook
CLI commandpercy-flags
- Flags to pass to thepercy-storybook
CLI commandworking-directory
(default:./
) - The directory for the commands to execute incustom-command
- Your own CLI command to build storybook & runpercy-storybook
. Useful for when you want complete control over what is ran.
snapshot-action
Checkout the action on GitHub
In the GitHub Marketplace
The snapshot-action
allows you to visually test any static site in GitHub Actions. It uses our Static sites SDK under the hood.
Quick start
To use the Percy static sites GitHub action you will need to add a new step to your actions config using the percy/snapshot-action
action. You will need to specify the build-directory
which your static site builds to. You will also need to set your PERCY_TOKEN
in your GitHub projects settings.
This is a sample config using the default setup. If you don't have an existing GitHub workflow file, you could place this example in <project_root>/.github/workflows/ci.yml
:
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Setup Ruby
uses: actions/setup-ruby@v1
- name: Install
run: bundle install
- name: Build
run: bundle exec jekyll build
- name: Default test
uses: percy/[email protected]
with:
build-directory: "_site"
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Setup Ruby
uses: actions/setup-ruby@v1
- name: Install
run: bundle install
- name: Build
run: bundle exec jekyll build
- name: Default test
uses: percy/[email protected]
with:
build-directory: "_site"
flags: "--base-url /marketing"
working-directory: "./static-site"
silence: false
verbose: true
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
Inputs
build-directory
- The directory where your static site outputs its build toflags
- Flags to pass to thepercy snapshot
CLI commandworking-directory
(default:./
) - The directory for the commands to execute insilence
- Silence the logging from Percyverbose
- Verbose debug logging from Percy
Updated over 1 year ago