GitHub Actions Integration
This guide helps you integrate Shiplight AI's automated testing into your GitHub CI/CD pipeline.
Table of Contents
- Prerequisites
- Step 1: Get Your Shiplight API Token
- Step 2: Add API Token to GitHub Secrets
- Step 3: Find Your Shiplight IDs
- Step 4: Create GitHub Workflow
- Configuration Options
- Action Outputs
- Test Account Configuration
- Troubleshooting
- Best Practices
- Support
Prerequisites
Before starting, you'll need:
- Admin access to your GitHub repository (to add secrets and workflows)
- A Shiplight AI account with test suites configured
- Your Shiplight API token
Step 1: Get Your Shiplight API Token
- Log into Shiplight AI
- Navigate to Settings → API Tokens
- Create a new API token or use an existing one
- Copy the token and keep it secure
⚠️ Important: Never commit your API token directly to your repository.
Step 2: Add API Token to GitHub Secrets
- Go to your GitHub repository
- Click Settings → Secrets and variables → Actions
- Click New repository secret
- Add your secret:
- Name:
SHIPLIGHT_API_TOKEN - Secret: Paste your API token
- Name:
- Click Add secret
Step 3: Find Your Shiplight IDs
You'll need these values from your Shiplight account:
Test Suite IDs
- Navigate to your test suites in Shiplight
- Note the ID(s) of the suite(s) you want to run
- You can run multiple suites by using comma-separated IDs
Environment ID
- Go to Settings → Environments
- Find your target environment
- Copy the Environment ID
Step 4: Create GitHub Workflow
Create a new file .github/workflows/shiplight-test.yml in your repository:
Basic Configuration (Pull Requests)
yaml
name: Shiplight AI Tests
on:
pull_request:
branches:
- main
- develop
# Required for commenting on pull requests
permissions: write-all
jobs:
test:
name: Run Shiplight Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Shiplight Tests
uses: ShiplightAI/github-action@v1
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 123 # Single suite
# test-suite-id: 123,456,789 # Multiple suites
environment-id: 1
# Optional: Override environment URL
# environment-url: https://staging.example.comAdvanced Configuration (With Deployment)
yaml
name: Deploy and Test
on:
pull_request:
branches:
- main
permissions: write-all
jobs:
deploy-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Your deployment step
- name: Deploy to Preview
id: deploy
run: |
# Your deployment script
echo "preview-url=https://preview-$\{{ github.event.number }}.example.com" >> $GITHUB_OUTPUT
- name: Run Shiplight Tests
uses: ShiplightAI/github-action@v1
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 123,456 # Multiple suites run in parallel
environment-id: 1
environment-url: ${{ steps.deploy.outputs.preview-url }}
timeout-seconds: 1800 # 30 minutes
commit-sha: $\{{ github.event.pull_request.head.sha }}Vercel Deployment Integration
For Vercel deployments, use repository dispatch:
yaml
name: Shiplight Tests on Vercel Deploy
on:
repository_dispatch:
types:
- "vercel.deployment.success"
permissions: write-all
jobs:
test:
# Only run for preview deployments
if: github.event.client_payload.environment == 'preview'
runs-on: ubuntu-latest
steps:
- name: Set commit status - pending
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.client_payload.git.sha,
state: 'pending',
context: 'Shiplight AI Tests',
description: 'Running tests...',
target_url: '$\{{ github.server_url }}/$\{{ github.repository }}/actions/runs/$\{{ github.run_id }}'
});
- name: Run Shiplight Tests
uses: ShiplightAI/github-action@v1
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 1,2,3 # Multiple suites
environment-id: 1
environment-url: $\{{ github.event.client_payload.url }}
commit-sha: $\{{ github.event.client_payload.git.sha }}
timeout-seconds: 1800
- name: Set commit status - complete
if: always()
uses: actions/github-script@v7
with:
script: |
const jobStatus = '${{ job.status }}';
const state = jobStatus === 'success' ? 'success' : 'failure';
const description = jobStatus === 'success'
? 'Tests passed'
: 'Tests failed';
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.client_payload.git.sha,
state: state,
context: 'Shiplight AI Tests',
description: description,
target_url: '$\{{ github.server_url }}/$\{{ github.repository }}/actions/runs/$\{{ github.run_id }}'
});Configuration Options
| Option | Required | Default | Description |
|---|---|---|---|
api-token | ✅ Yes | - | Your Shiplight API token |
test-suite-id | ✅ Yes | - | Single ID or comma-separated list (e.g., "1" or "1,2,3") |
environment-id | ✅ Yes | - | Shiplight environment ID |
environment-url | No | - | Override the environment's configured URL |
github-comment | No | true | Comment on pull requests with results |
github-token | No | GITHUB_TOKEN | Token for PR comments (auto-provided) |
async | No | false | Launch tests without waiting (disables comments) |
commit-sha | No | - | Specific commit SHA for finding the PR |
timeout-seconds | No | 86400 | Maximum wait time (default: 24 hours) |
Multiple Test Suites
The action supports running multiple test suites in parallel for efficiency:
yaml
test-suite-id: 1 # Single suite
test-suite-id: 1,2,3 # Multiple suites (run in parallel)Action Outputs
The action provides outputs you can use in subsequent steps:
| Output | Description |
|---|---|
success | Whether all test runs were successful (true/false) |
results | JSON string containing detailed results for each test suite |
Using Outputs
yaml
- name: Run Shiplight Tests
id: shiplight
uses: ShiplightAI/github-action@v1
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 1,2
environment-id: 1
- name: Check Results
if: steps.shiplight.outputs.success == 'false'
run: |
echo "Tests failed!"
echo "Results: ${{ steps.shiplight.outputs.results }}"
exit 1Test Account Configuration
If your tests require authentication, configure test accounts in Shiplight:
- Navigate to Settings → Test Accounts
- Click Add Test Account
- Select the environment (scope)
- Enter credentials
- Save the account
The test runner will automatically use the appropriate test account based on the environment ID.
Troubleshooting
Workflow Not Running
- Verify the workflow file is in
.github/workflows/ - Check that the file extension is
.ymlor.yaml - Ensure the trigger event matches your needs
Authentication Failed
- Verify the API token is correct
- Check that the secret name is exactly
SHIPLIGHT_API_TOKEN - Ensure the token has necessary permissions
No PR Comments
- Add
permissions: write-allto your workflow - Verify
github-commentis not set tofalse - Check that the action is running on a pull request event
Tests Timing Out
- Increase
timeout-secondsvalue - Check if your test suites are too large
- Consider splitting into smaller suites
Multiple Suites Not Running
- Ensure you're using the latest action version (
@v1or later) - Verify suite IDs are comma-separated without spaces
Best Practices
- Use Multiple Suites: Run related tests in parallel for faster feedback
- Set Appropriate Timeouts: Balance between allowing enough time and failing fast
- Environment URLs: Use dynamic URLs for preview deployments
- Commit SHA: Specify for accurate PR matching in complex workflows
- Monitor Usage: Check your Shiplight dashboard for test execution metrics
Support
- Check test results: Shiplight Dashboard
- Get help: Contact your Shiplight support team