Skip to main content

API Reference

Complete reference for the Webshot Archive API and GitHub Action.

GitHub Action

The Webshot Archive GitHub Action is the primary way to upload screenshots and generate visual comparisons in your CI/CD pipeline.

Prerequisites

Before using the GitHub Action, make sure you have:

Basic Usage

- name: Upload Screenshots
uses: webshotarchive/github-[email protected]
with:
screenshotsFolder: cypress/screenshots
clientId: ${{ secrets.WSA_CLIENT_ID }}
clientSecret: ${{ secrets.WSA_CLIENT_SECRET }}
projectId: ${{ secrets.WSA_PROJECT_ID }}

Action Parameters

ParameterTypeRequiredDefaultDescription
screenshotsFolderstringYes-Path to folder containing screenshots to upload
clientIdstringYes-Your Webshot Archive client ID
clientSecretstringYes-Your Webshot Archive client secret
projectIdstringYes-Your Webshot Archive project ID
failedTestPatternstringNo"failed"Regex pattern to match failed test screenshots
commitShastringNo${{github.event.pull_request.head.sha}} (PR)
${{github.event.after}} (Push)
Commit SHA for the current screenshots
compareCommitShastringNo${{github.event.pull_request.base.sha}} (PR)
${{github.event.before}} (Push)
Commit SHA to compare against
branchNamestringNo${{github.head_ref}} (PR)
${GITHUB_REF##*/} (Push)
Branch name for the screenshots
mergedBranchstringNo-Branch that was merged (for merge events)
commentbooleanNotrue (PR)
false (Push)
Whether to comment on the PR
tagsstringNoAuto-generatedTags to add to screenshots
compareBranchstringNo-Deprecated: Use compareCommitSha instead

Parameter Details

Required Parameters

screenshotsFolder - Path to the folder containing your screenshots

  • Cypress: cypress/screenshots/
  • Playwright: test-results/ or custom path
  • Selenium: screenshots/

clientId & clientSecret - Your API credentials

projectId - Your Webshot Archive project ID

  • Found in your project dashboard
  • Each project has a unique ID

Optional Parameters

failedTestPattern - Regex to identify failed test screenshots

  • Default: "failed"
  • Examples: "error", "failure", "(failed)"

commitSha & compareCommitSha - Git commit references

  • Automatically set based on GitHub event context
  • Override for custom comparison logic

comment - Whether to post PR comments

  • true for pull requests (default)
  • false for push events (default)

tags - Custom tags for screenshots

  • Auto-generated based on filename patterns
  • Manual tags: "mobile,desktop,homepage"

Tag Generation Logic

The action automatically generates tags based on:

  1. Failed tests: Files ending in (failed).png get failed tag
  2. Custom tags: Files with tags-[tag1,tag2,tag3] in filename get those tags
  3. Manual tags: Tags specified in the tags parameter

Basic Configuration

- name: Upload Screenshots
uses: webshotarchive/github-[email protected]
with:
screenshotsFolder: cypress/screenshots
clientId: ${{ secrets.WSA_CLIENT_ID }}
clientSecret: ${{ secrets.WEBSHOT_ARCHIVE_CLIENT_SECRET }}
projectId: ${{ secrets.WEBSHOT_ARCHIVE_PROJECT_ID }}

Advanced Configuration

- name: Upload with Custom Settings
uses: webshotarchive/github-[email protected]
with:
screenshotsFolder: test-results
clientId: ${{ secrets.WSA_CLIENT_ID }}
clientSecret: ${{ secrets.WEBSHOT_ARCHIVE_CLIENT_SECRET }}
projectId: ${{ secrets.WEBSHOT_ARCHIVE_PROJECT_ID }}
failedTestPattern: 'error'
tags: 'mobile,desktop,ci'
comment: true

Environment-Specific Configuration

- name: Upload Staging Screenshots
uses: webshotarchive/github-[email protected]
with:
screenshotsFolder: cypress/screenshots
clientId: ${{ secrets.WSA_CLIENT_ID }}
clientSecret: ${{ secrets.WEBSHOT_ARCHIVE_CLIENT_SECRET }}
projectId: ${{ secrets.WEBSHOT_ARCHIVE_PROJECT_ID }}
tags: 'staging,automated'
comment: false # Don't comment on staging builds

Error Handling

The action provides detailed error information when things go wrong:

Common Error Responses

Authentication Error:

{
"error": "Invalid client credentials"
}

Project Not Found:

{
"error": "Project not found or access denied"
}

Screenshots Not Found:

{
"error": "No screenshots found in specified folder"
}

Debug Mode

Enable debug logging for troubleshooting:

- name: Upload with Debug
uses: webshotarchive/github-[email protected]
env:
ACTIONS_STEP_DEBUG: true # Enable detailed logging
with:
screenshotsFolder: cypress/screenshots
clientId: ${{ secrets.WSA_CLIENT_ID }}
clientSecret: ${{ secrets.WSA_CLIENT_SECRET }}
projectId: ${{ secrets.WSA_PROJECT_ID }}
{
"data": {
"originalName": "web-ui-e2e -- Hero.png",
"path": "dist/cypress/apps/web-ui-e2e/screenshots/app.cy.ts/web-ui-e2e -- Hero.png",
"userId": "6739e6d10d48b487ba80222b",
"project": "***",
"isDuplicate": false,
"isDeleted": false,
"bucketPath": "6739e6d10d48b487ba80222b/f1db95ff8605a53fd28ae011f8cbe8ad876dc5e8/1065e815-341c-4d51-806b-0524b73dd354.png",
"commitSha": "f1db95ff8605a53fd28ae011f8cbe8ad876dc5e8",
"mimeType": "image/png",
"bucket": "timechain-actions",
"uniqueId": "1065e815-341c-4d51-806b-0524b73dd354",
"size": 637329,
"branchName": "main",
"mergedBranch": "main",
"eventName": "merge",
"tags": ["release"],
"metaVersion": 1,
"createdAt": "2024-11-26T01:00:09.191Z",
"updatedAt": "2024-11-26T01:00:09.191Z",
"id": "67451d99fc442a32bd6e69dd"
},
"metadata": {
"compareCommitSha": "9885f81d2c1b104c41970b8e018045390e16b306",
"compareImage": "3b6efc32-51f4-46b9-9685-67a728f570b6",
"metadata": true
},
"error": "Error: Image sizes do not match."
}

API Endpoints

Update Images

Provides a way to update image metadata. Useful for adding/updating tags.

URL: /api/image/update/${projectId}/update-images

Request

body:

const headers = {
'x-client-id': '<client-id>',
'x-client-secret': '<client-secret>',
};
const body = {
find: {
commitSha: 'f1db95ff8605a53fd28ae011f8cbe8ad876dc5e8',
},
update: {
tags: ['release', 'production'],
// "path": "new/path/to/image.png",
// "originalName": "renamed-image.png",
// "commitSha": "updated-sha-value",
// "branchName": "feature/new-branch",
// "mergedBranch": "main",
// "eventName": "merge"
},
};
await axios.post(
`https://api.webshotarchive.com/api/image/update/${projectId}/update-images`,
body,
{
headers,
}
);

Path Parameters

ParameterTypeRequiredDescription
projectIdstringYesThe project ID

Body Parameters

ParameterTypeRequiredDescription
findobjectYesThe object to find
find.commitShastringNoThe sha to match on
find.branchNamestringNoThe branch name to match on
find.eventNamestringNoThe event name to match on
find.pathstringNoThe path to match on
find.originalNamestringNoThe original name to match on
find.tagsstring[]NoThe tags to match on
updateobjectYesThe object to update
update.tagsstring[]YesThe tags to set
update.pathstringNoThe path to set
update.originalNamestringNoThe original name to set
update.commitShastringNoThe commit sha to set
update.branchNamestringNoThe branch name to set
update.mergedBranchstringNoThe merged branch to set
update.eventNamestringNoThe event name to set