Multiple projects per repo


Covered in this doc

How to configure multiple projects per repository

Percy supports having multiple Percy projects associated with one repository. This is particularly useful when you organize your code in a mono-repo, or have different types of test suites, static sites, or storybooks in one repository.

When projects are configured this way, each project will report its status individually on a GitHub pull request or GitLab merge request.

Configuring multiple projects per repository

This section assumes that you have one CI script that runs all tests in your repo. You should ensure you run a full set of snapshots for each project on every master-branch build, to keep your baseline snapshots up-to-date with your latest code.

  • Visit the Percy settings page for your projects, and ensure they're all linked to the same repository.
  • Update your CI system's environment variables to include the PERCY_TOKEN for each project, each with a different environment variable name. i.e. PERCY_TOKEN_PROJECT_A=... and PERCY_TOKEN_PROJECT_B=...
  • Update your CI script to set PERCY_TOKEN to the correct value when the appropriate step is executed, by wrapping the environment variable's name in ${...}.

For example, your CI script that sends snapshots to 2 different projects may look like this:

npm install
PERCY_TOKEN=${PERCY_TOKEN_PROJECT_B} npm run storybook-snapshots

If you have questions about associating multiple projects with one repository, please feel free to contact support.