> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wundertest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Actions

Integrate Wundertest with your GitHub workflow to automatically run tests after deployments. This guide will walk you through setting up GitHub Actions with Wundertest.

## Setup Instructions

1. Go to **Settings** on the [Wundertest dashboard](https://wundertest.ai/app)
2. Create a new API Key, name it "GitHub Action"
3. Copy your organization ID from the settings page and add it to your GitHub repository secrets as `WUNDERTEST_ORG_ID`
4. Add the API Key to your GitHub repository secrets as `WUNDERTEST_TOKEN`
5. Add a workflow that works for your deployment process.

## Example GitHub Actions Workflow File

This workflow would run on every push to the main branch and can also be triggered manually.

```yaml theme={null}
name: Deploy and Test

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  deploy:
    # ... Your deploy workflow
  wundertest:
    needs: [deploy]
    runs-on: ubuntu-latest

    env:
      WUNDERTEST_TOKEN: ${{ secrets.WUNDERTEST_TOKEN }}
      WUNDERTEST_ORG_ID: ${{ secrets.WUNDERTEST_ORG_ID }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "18"

      - name: Install Wundertest CLI
        run: npm install -g wundertest@latest

      - name: Run Wundertest Tests
        run: |
          wundertest run
```

## Vercel

If you are using Vercel with branch deployments, you might want to check out our guide for [Vercel](/vercel-integration).

## How It Works

This workflow will:

1. Run after your deployment job completes
2. Set up Node.js environment
3. Install the latest version of the Wundertest CLI
4. Run your Wundertest tests against the newly deployed environment
5. The workflow will fail if any of the tests fail

If you don't want to fail the deployment, you can use the `wundertest run --trigger-only` command. This will just
trigger the tests but not fail the deployment.

## Using the API Directly

If you have concerns with using the Wundertest CLI and you just want to trigger tests, you can send a request to our API directly:

```yaml theme={null}
- name: Run Wundertest
  run: |
    curl -X POST "https://api.wundertest.ai/api/test-runs" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer ${{ secrets.WUNDERTEST_TOKEN }}" \
      -d '{
        "organizationId": "${{ secrets.WUNDERTEST_ORG_ID }}",
        "testCaseIds": null
      }'
  env:
    WUNDERTEST_TOKEN: ${{ secrets.WUNDERTEST_TOKEN }}
    WUNDERTEST_ORG_ID: ${{ secrets.WUNDERTEST_ORG_ID }}
```

This approach is useful if you want to avoid installing Node.js and the CLI, or if you're working in an environment where using the CLI is not practical.

## References

* [GitHub Actions Documentation](https://docs.github.com/en/actions)
