Skip to main content

CI/CD workflow integration


Here we are going to discuss how to integrate Diffy with your CI workflow.


First of all, you will need to use a docker image with PHP and install our CLI tool. If you are using something like CircleCI you could install it with 



Then you need to authenticate the tool with your API key. You can find it under My Account -> Keys in the app's UI.

php diffy.phar auth:login $DIFFY_API_KEY


We highly recommend keeping API's key as an environmental variable in your CI. Here is an example of how Circle CI  and Bitbucket do that.


Next, you can run your compare command.


For example, if you compare just two environments (on the event of rebuilding staging environment)

php diffy.phar project:compare $DIFFY_PROJECT_ID prod stage


Or if you are building custom environments per pull request your command could look like

php diffy.phar project:compare $DIFFY_PROJECT_ID prod custom --env1Url=$CUSTOM_URL


If you would like to use Diffy's GitHub check you would also need to add a commit sha to the compare command:

LAST_GIT_COMMIT_HASH=$(git log -1 --pretty=%H)
php diffy.phar project:compare $DIFFY_PROJECT_ID prod custom --env1Url=$CUSTOM_URL  --commit-sha="${LAST_GIT_COMMIT_HASH}"


If you don't want to run visual testing for every commit you could also filter by commit message. Here is an example how to skip triggering Diffy jobs if latest commit doesn't have [vr] in it


LAST_GIT_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ ${LAST_GIT_COMMIT_MESSAGE} != *"[vr]"* ]]
    exit 0
    echo -e "\nRunning visual regression tests because the latest commit message demands it"