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) β
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) β
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@v2.0.0
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 123,456 # Multiple suites run in parallel
environment-id: 1
preflight-test-case-id: 123 # Optional, use if you need to run a preflight test case before the main tests
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:
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@v2.0.0
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 1,2,3 # Multiple suites
environment-id: 1
preflight-test-case-id: 123 # Optional, use if you need to run a preflight test case before the main tests
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 |
preflight-test-case-id | No | - | Shiplight preflight test case ID, run before the main tests |
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) |
test-context | No | - | Multi-line key-value context passed to the test run (e.g. env, branch, build-id) |
Multiple Test Suites β
The action supports running multiple test suites in parallel for efficiency:
test-suite-id: 1 # Single suite
test-suite-id: 1,2,3 # Multiple suites (run in parallel)Test Context β
Available in v2.0.0+. Use test-context to pass key-value context (e.g. environment, branch, build ID, API keys) into your test run. The value is multi-line; each line is typically key=value.
- name: Run Shiplight Tests
uses: ShiplightAI/github-action@v2.0.0
with:
api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }}
test-suite-id: 123
environment-id: 1
test-context: |
env=${{ vars.DEPLOY_ENV }}
branch=${{ github.ref_name }}
build-id=${{ github.run_id }}
api-key=${{ secrets.STAGING_API_KEY }}Preflight Test Case β
The action supports running a preflight test case before the main tests. The preflight runs first; only when it passes will the main test suite(s) run.
preflight-test-case-id: 123 # Optional, run before the main testsWhen to use a preflight test case
| Scenario | Description |
|---|---|
| Smoke / health check | Run a single quick test (e.g. login or homepage load) to confirm the environment is up and reachable before running the full suite. Saves time and credits when the deployment is broken. |
| Gate before heavy tests | Use one lightweight test as a gate: if it fails, skip the rest. Reduces noise from cascading failures and speeds up feedback when the app is clearly broken. |
| Auth / session setup | Use a preflight that performs login or session setup; main tests can assume an authenticated state and focus on feature flows. |
| Preview / ephemeral URLs | After deploying to a preview URL, run a preflight that hits that URL to verify the deployment succeeded before running the full suite against it. |
| Flaky or order-dependent tests | Isolate a critical path (e.g. βcan we complete one full flow?β) in the preflight so the main suite runs only when that path is stable. |
Upgrading from v1 to v2.0.0 β
If you are currently using the action at @v1 and want to use preflight test cases (preflight-test-case-id) or test context (test-context), upgrade to v2.0.0 as follows.
What changes
| Item | v1 | v2.0.0 |
|---|---|---|
| Action reference | ShiplightAI/github-action@v1 | ShiplightAI/github-action@v2.0.0 |
| Preflight support | Not available | Optional preflight-test-case-id |
| Test context | Not available | Optional test-context (multi-line key-value) |
Steps to upgrade
Update the action version in your workflow file (e.g.
.github/workflows/shiplight-test.yml):yaml# Before (v1) - name: Run Shiplight Tests uses: ShiplightAI/github-action@v1 # After (v2.0.0) - name: Run Shiplight Tests uses: ShiplightAI/github-action@v2.0.0(Optional) Add preflight β To run a single test case before your main suites, add
preflight-test-case-idwith the test case ID from Shiplight:yaml- name: Run Shiplight Tests uses: ShiplightAI/github-action@v2.0.0 with: api-token: ${{ secrets.SHIPLIGHT_API_TOKEN }} test-suite-id: 123,456 environment-id: 1 preflight-test-case-id: 789 # optional: run before main tests(Optional) Add test context β To pass env, branch, build-id, or other key-value context into your test run, add
test-context(see Test Context).No other changes required β Existing inputs (
api-token,test-suite-id,environment-id,environment-url,timeout-seconds, etc.) work the same in v2.0.0. You can upgrade first and addpreflight-test-case-idortest-contextlater when needed.
Summary
- Replace
@v1with@v2.0.0in theusesline. - Optionally set
preflight-test-case-idto run a preflight before the main test suites. - Optionally set
test-contextto pass key-value context (env, branch, build-id, etc.) into the test run.
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 β
- 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