Skip to content
Join Now Login

GitHub Actions

The official Gaffer Uploader GitHub Action makes it easy to automatically upload test reports from your CI workflows.

  1. Go to your GitHub repository
  2. Navigate to SettingsSecrets and variablesActions
  3. Click New repository secret
  4. Name: GAFFER_UPLOAD_TOKEN
  5. Value: Your Gaffer project upload token

Add the Gaffer uploader step after your test step. Use if: always() to ensure reports are uploaded even when tests fail.

InputRequiredDescription
gaffer_api_keyYesYour Gaffer project upload token
report_pathYesPath to the report file or directory to upload
api_endpointNoCustom API endpoint URL (for staging/preview environments)
commit_shaNoGit commit SHA to associate with the test run
branchNoGit branch name to associate with the test run
test_frameworkNoTest framework used (e.g., playwright, jest, pytest)
test_suiteNoName of the test suite (e.g., unit, e2e)
name: Tests
on: push
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 tests
run: npm test
- name: Upload to Gaffer
uses: gaffer-sh/gaffer-uploader@v1
if: always()
with:
gaffer_api_key: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: ./test-results
commit_sha: ${{ github.sha }}
branch: ${{ github.ref_name }}

A complete example for Playwright tests:

name: Playwright Tests
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Install Playwright browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- name: Upload Playwright Report to Gaffer
uses: gaffer-sh/gaffer-uploader@v1
if: always()
with:
gaffer_api_key: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: ./playwright-report
commit_sha: ${{ github.sha }}
branch: ${{ github.ref_name }}
test_framework: playwright
test_suite: e2e

For pull request workflows, use github.head_ref to get the correct branch name:

name: PR Tests
on:
pull_request:
branches: [main]
env:
branch_name: ${{ github.head_ref || github.ref_name }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test
- name: Upload to Gaffer
uses: gaffer-sh/gaffer-uploader@v1
if: always()
with:
gaffer_api_key: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: ./test-results
commit_sha: ${{ github.event.pull_request.head.sha }}
branch: ${{ env.branch_name }}
test_framework: jest
test_suite: unit

For a standardized format across all your test frameworks, consider using CTRF:

- name: Install CTRF reporter
run: npm install --save-dev jest-ctrf-json-reporter # or playwright-ctrf-json-reporter, vitest-ctrf-json-reporter
- name: Run tests with CTRF reporter
run: npm test -- --reporter=jest-ctrf-json-reporter
- name: Upload CTRF report to Gaffer
uses: gaffer-sh/gaffer-uploader@v1
if: always()
with:
gaffer_api_key: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: ./ctrf-report.json
commit_sha: ${{ github.sha }}
branch: ${{ github.ref_name }}

GitHub Actions provides these variables for your workflow:

VariableDescriptionExample
${{ github.sha }}Full commit SHAabc123def456...
${{ github.ref_name }}Branch or tag namemain, feature/login
${{ github.head_ref }}PR source branch (PR workflows only)feature/login
${{ github.event.pull_request.head.sha }}PR head commit SHAdef456abc789...
  • Verify the report_path points to the correct file or directory
  • Check that your upload token secret is named exactly GAFFER_UPLOAD_TOKEN
  • Ensure if: always() is set so the step runs even when tests fail

For pull request workflows, use github.head_ref || github.ref_name pattern to get the correct source branch name.

  • Check your upload token starts with gfr_
  • Verify the token is correctly copied (no extra spaces)
  • Make sure the secret is accessible to the workflow

Other CI Providers: GitLab CI · CircleCI · Jenkins · Bitbucket · Azure DevOps