GitHub Actions Integration
GoDiffy provides a powerful GitHub Action that fully automates visual regression testing in your CI/CD pipeline. Unlike other solutions, you don't need to write screenshot capture codeβGoDiffy handles everything: screenshot capture, upload, comparison, and reporting.
No Screenshot Code Requiredβ
Just provide a config file with your URLs, and GoDiffy automatically:
- π― Captures screenshots from your deployed applications
- π€ Uploads them to secure cloud storage
- π Compares them against your baseline
- π Generates detailed reports
- π¬ Posts results as PR comments
You focus on your app, we handle the visual testing.
Traditional Approach vs. GoDiffyβ
| β Traditional Approach | β GoDiffy Approach |
|---|---|
| |
Quick Startβ
1. Get Your API Credentialsβ
- Sign up for GoDiffy if you haven't already
- Create a site for your project in the GoDiffy dashboard
- Generate an API key in your account settings
- Copy your site ID from the site settings
2. Add GitHub Secretsβ
Add your GoDiffy credentials as repository secrets:
- Go to Settings β Secrets and variables β Actions
- Add these secrets:
GODIFFY_API_KEY: Your GoDiffy API keyGODIFFY_SITE_ID: Your site ID (optional, can be in config file)
3. Create Configuration Fileβ
Create godiffy.json in your repository root:
{
"siteId": "your-site-id",
"baseUrls": {
"master": "https://your-app-production.com",
"dev": "https://your-app-dev.com"
},
"pages": [
{
"name": "home",
"path": "/"
},
{
"name": "features",
"path": "/features"
},
{
"name": "pricing",
"path": "/pricing"
}
],
"viewport": {
"width": 1280,
"height": 720
},
"threshold": 0.95,
"algorithm": "pixelmatch"
}
4. Create Workflowβ
Create .github/workflows/visual-regression.yml:
That's it! No need to install Playwright, write screenshot code, or manage storage. GoDiffy handles everything automatically.
name: Visual Regression Testing
on:
push:
pull_request:
jobs:
upload-screenshots:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Capture and upload screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: true
config-path: './godiffy.json'
create-report: false
compare-screenshots:
if: github.event_name == 'pull_request' || github.ref != 'refs/heads/master'
needs: upload-screenshots
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Wait for uploads to process
run: sleep 5
- name: Run visual regression comparison
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: false
config-path: './godiffy.json'
baseline-branch: ${{ github.base_ref }}
baseline-commit: latest
create-report: true
post-pr-comment: true
github-token: ${{ secrets.GITHUB_TOKEN }}
Notice there's no screenshot capture code in this workflow!
The capture-screenshots: true parameter tells GoDiffy to:
- Launch a headless browser
- Navigate to each URL in your
godiffy.json - Capture full-page screenshots
- Upload them to secure cloud storage
- Compare against your baseline
All automatically. You just provide the URLs and configuration.
Configuration Referenceβ
Action Inputsβ
| Input | Required | Description | Default |
|---|---|---|---|
api-key | β | Your GoDiffy API key | - |
site-id | β | Your site ID | - |
config-path | β | Path to godiffy.json config file | ./godiffy.json |
capture-screenshots | β | Whether to capture screenshots | true |
images-path | β | Path to pre-captured screenshots | - |
create-report | β | Whether to create a comparison report | true |
baseline-branch | β | Branch to compare against | master |
baseline-commit | β | Specific commit or "latest" | latest |
threshold | β | Similarity threshold (0-1) | From config file |
algorithm | β | Comparison algorithm | From config file |
post-pr-comment | β | Automatically post PR comment with results | false |
github-token | β | GitHub token for PR comments | secrets.GITHUB_TOKEN |
Action Outputsβ
| Output | Description |
|---|---|
total-comparisons | Total number of comparisons performed |
passed-comparisons | Number of comparisons that passed |
failed-comparisons | Number of comparisons that failed |
average-similarity | Average similarity percentage (0-100) |
threshold-met | Whether threshold was met (true/false) |
report-id | ID of the generated report |
report-url | URL to view the report |
Configuration File (godiffy.json)β
{
"siteId": "your-site-id",
"baseUrls": {
"master": "https://production-url.com",
"dev": "https://dev-url.com",
"staging": "https://staging-url.com"
},
"pages": [
{
"name": "home",
"path": "/"
},
{
"name": "about",
"path": "/about"
}
],
"viewport": {
"width": 1280,
"height": 720
},
"threshold": 0.95,
"algorithm": "pixelmatch"
}
Configuration Options:
siteId: Your GoDiffy site identifierbaseUrls: URLs for different branches/environmentspages: Array of pages to screenshotname: Identifier for the screenshot filepath: URL path to capture
viewport: Browser viewport dimensionswidth: Viewport width in pixelsheight: Viewport height in pixels
threshold: Similarity threshold (0-1, where 1 = identical)algorithm: Comparison algorithm (pixelmatch,ssim,mse)
Usage Patternsβ
Basic Screenshot Captureβ
Capture screenshots from your deployed application:
- name: Capture screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: true
config-path: './godiffy.json'
Upload Pre-Captured Screenshotsβ
If you already have screenshots from your test suite:
- name: Upload existing screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: false
images-path: './screenshots'
config-path: './godiffy.json'
Run Comparisonβ
Compare current branch against baseline:
- name: Compare screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: false
baseline-branch: master
baseline-commit: latest
create-report: true
config-path: './godiffy.json'
Custom Thresholdβ
Override the threshold from config:
- name: Compare with custom threshold
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
threshold: 0.92
algorithm: ssim
Pull Request Integrationβ
Automatic PR Commentsβ
Enable automatic PR comments by setting post-pr-comment: true:
- name: Compare screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
create-report: true
post-pr-comment: true
github-token: ${{ secrets.GITHUB_TOKEN }}
That's all you need! The action will automatically:
- Find the PR number (works for both
pull_requestandpushevents) - Fetch the comparison report from the API
- Post a formatted comment with results
- Fail the workflow if threshold not met
Example Comment:
## β Visual Regression Report - FAILED
**Results:** 0/4 comparisons passed
**Average Similarity:** 46.13%
**Threshold:** 95%
β οΈ **Visual changes detected that exceed the acceptable threshold**
β οΈ 4 comparison(s) below individual threshold
**π [View Full Report](https://godiffy-backend.up.railway.app/sites/.../reports/...)**
---
*Generated by GoDiffy GitHub Action*
Unlike other solutions, you don't need to write any github-script code or manage API calls. Just set post-pr-comment: true and the action handles everything.
Status Checksβ
The action integrates with GitHub's status check system:
- β Success: All comparisons pass the threshold
- β Failure: Comparisons fall below threshold
- The workflow will fail if
threshold-metisfalse
Branch Protectionβ
Require visual regression checks before merging:
- Go to Settings β Branches
- Edit your branch protection rule
- Enable "Require status checks to pass before merging"
- Select "compare-screenshots" from the list
Complete Examplesβ
Full Two-Job Workflowβ
name: Visual Regression Testing
on:
push:
pull_request:
jobs:
upload-screenshots:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Capture and upload screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: true
config-path: './godiffy.json'
create-report: false
compare-screenshots:
if: github.event_name == 'pull_request' || github.ref != 'refs/heads/master'
needs: upload-screenshots
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Wait for processing
run: sleep 5
- name: Compare screenshots
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: false
baseline-branch: ${{ github.base_ref }}
baseline-commit: latest
create-report: true
post-pr-comment: true
github-token: ${{ secrets.GITHUB_TOKEN }}
config-path: './godiffy.json'
Single Job Workflowβ
name: Visual Testing
on:
pull_request:
jobs:
visual-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run visual regression test
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: true
create-report: true
config-path: './godiffy.json'
With Custom Test Suiteβ
name: E2E + Visual Testing
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run E2E tests (generates screenshots)
run: npm run test:e2e
- name: Upload screenshots to GoDiffy
uses: GoDiffy/godiffy-github-actions@v1
with:
api-key: ${{ secrets.GODIFFY_API_KEY }}
site-id: ${{ secrets.GODIFFY_SITE_ID }}
capture-screenshots: false
images-path: './test-results/screenshots'
create-report: true
Best Practicesβ
1. Consistent Screenshotsβ
- Use fixed viewport sizes
- Wait for animations to complete
- Mock or freeze dynamic content (dates, random data)
- Ensure fonts are fully loaded
2. Threshold Selectionβ
- 0.95-0.99: Strict, catches small changes
- 0.90-0.95: Moderate, allows minor differences
- 0.85-0.90: Lenient, only catches major changes
3. Performance Optimizationβ
- Capture screenshots in parallel when possible
- Use
images-pathto upload pre-captured screenshots - Limit the number of pages to essential ones
- Use appropriate viewport sizes
4. Workflow Organizationβ
- Separate upload and compare jobs for better control
- Use
continue-on-error: trueto ensure PR comments post - Add appropriate
permissionsfor PR comments - Use
ifconditions to control when comparisons run
Troubleshootingβ
Screenshots Not Uploadingβ
Problem: Screenshots aren't appearing in GoDiffy
Solutions:
- Verify API key and site ID are correct
- Check that
capture-screenshots: trueis set - Ensure URLs in
godiffy.jsonare accessible - Review workflow logs for error messages
Comparisons Always Passβ
Problem: Comparisons show 100% similarity despite changes
Solutions:
- Ensure baseline images exist on the master branch
- Check that different URLs are configured for different branches
- Verify the comparison is using the correct commits
- Wait a few seconds between upload and compare jobs
PR Comments Not Postingβ
Problem: No comment appears on pull requests
Solutions:
- Add
pull-requests: writepermission to the job - Ensure the PR comment script is included in your workflow
- Check that
GODIFFY_API_KEYsecret is set - Verify the report was created successfully
Flaky Testsβ
Problem: Comparisons fail inconsistently
Solutions:
- Add wait times for React/Vue hydration (
await page.waitForTimeout(2000)) - Use
waitUntil: 'networkidle'in Playwright - Mock dynamic content (timestamps, random IDs)
- Increase threshold slightly (e.g., 0.95 β 0.93)
Action Version Issuesβ
Problem: Action behavior changes unexpectedly
Solutions:
- Pin to a specific version:
@v1.0.0instead of@v1 - Review the changelog
- Test in a separate branch before updating
Demo Repositoryβ
See a complete working example:
π godiffy-github-demo
This demo repository shows:
- Complete workflow configuration
- PR with visual regression failures
- Automatic PR comments
- Screenshot capture from deployed apps
- Threshold-based pass/fail logic
Resourcesβ
- Action Repository - Source code and releases
- Demo Repository - Working example
- API Documentation - Backend API reference
- Features Guide - Platform capabilities
Getting Helpβ
If you need assistance:
- Check the demo repository for working examples
- Review workflow logs for error messages
- Open an issue on GitHub
- Contact support at support@godiffy.app
Next Steps:
- Explore Features to learn about advanced capabilities
- Review API Documentation for custom integrations
- Learn Visual Regression Concepts to understand best practices