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

# CI/CD with GitHub Actions

> Run Tuner simulations after every deploy from a GitHub Actions workflow, with a pass/fail check, a pull request comment and a job summary.

> [!NOTE]
>
> The Action runs on Linux and macOS runners that have `npm`. GitHub-hosted runners have it. Before you start, you need:
>
> * A [Tuner API key](https://docs.usetuner.ai/docs/getting-started/api-keys.md#create-a-tuner-api-key).
> * The agent's [Agent Remote ID](https://docs.usetuner.ai/docs/getting-started/api-keys.md#find-your-agent-remote-id).
> * [Inbound](https://docs.usetuner.ai/docs/simulation/inbound/setup.md) or [outbound](https://docs.usetuner.ai/docs/simulation/outbound.md) simulation set up for the agent.
> * Scenarios with a shared tag, such as `smoke`, in the [Scenario Library](https://docs.usetuner.ai/docs/simulation/scenarios.md).

Run your simulations after every deploy and stop a bad change before it reaches production. The Tuner GitHub Action runs a tag's Scenarios with the [Tuner CLI](https://docs.usetuner.ai/docs/simulation/cli.md), which it installs at a pinned version. The result appears on the job as a pass/fail check and a job summary, and on pull requests as one comment that updates on every push.

On GitLab CI, CircleCI or Jenkins? See [Other CI tools](https://docs.usetuner.ai/docs/simulation/ci/other-tools.md).

## Deploy first, then test

A simulation calls your agent as it is deployed at that moment, so a pull request tests nothing until its change is running. Tuner doesn't deploy anything.

Deploy the change to a staging agent in your own workflow, and add `needs:` so the Tuner job waits for the deploy job. Use a separate Tuner agent for the staging deployment, so CI runs stay apart from your production runs.

## Set up the Action

**1. Add the API key as a secret**

In your repository, go to **Settings > Secrets and variables > Actions** and add a repository secret named `TUNER_API_KEY`.

**2. Add the agent as a variable**

On the same page, add a repository variable named `TUNER_AGENT_ID` with the staging agent's Agent Remote ID.

**3. Copy a workflow**

Copy [Test after merge](#test-after-merge) or [Test on pull requests](#test-on-pull-requests) into `.github/workflows/`, and replace the deploy step with your own.

## Test after merge

This workflow runs when a change reaches `main`. It deploys to staging, then runs the simulations. If they pass, you can promote the change to production.

```yaml theme={null}
name: voice-agent-tests
on:
  push:
    branches: [main]

permissions:
  contents: read

concurrency:
  group: tuner-${{ vars.TUNER_AGENT_ID }}

jobs:
  deploy-staging:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/deploy-staging.sh # replace with your own deploy

  simulations:
    needs: deploy-staging
    runs-on: ubuntu-latest
    timeout-minutes: 70 # keep above the action's timeout
    steps:
      - uses: usetuner/tuner-action@v1
        with:
          api-key: ${{ secrets.TUNER_API_KEY }}
          agent: ${{ vars.TUNER_AGENT_ID }}
          tag: smoke
```

The `concurrency` group is named after the agent, so GitHub runs one workflow for the agent at a time. An agent runs one simulation at a time, and a second workflow would otherwise fail with "agent already has a run in progress".

A push to `main` has no pull request, so the Action posts no comment. The check and the job summary still appear, and the run records where it came from.

## Test on pull requests

This workflow deploys the pull request's branch to staging, then runs the simulations. Use it only if your team already deploys pull requests to staging.

```yaml theme={null}
name: voice-agent-tests
on: pull_request

permissions:
  contents: read
  pull-requests: write # lets the action post its pull request comment

concurrency:
  group: tuner-${{ vars.TUNER_AGENT_ID }}

jobs:
  deploy-staging:
    if: github.event.pull_request.head.repo.fork == false
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/deploy-staging.sh # replace with your own deploy

  simulations:
    needs: deploy-staging
    if: github.event.pull_request.head.repo.fork == false
    runs-on: ubuntu-latest
    timeout-minutes: 70 # keep above the action's timeout
    steps:
      - uses: usetuner/tuner-action@v1
        with:
          api-key: ${{ secrets.TUNER_API_KEY }}
          agent: ${{ vars.TUNER_AGENT_ID }}
          tag: smoke
```

GitHub gives pull requests from forks no secrets, so the `if:` lines skip them.

## What you see on GitHub

The Action turns the CLI's [exit code](https://docs.usetuner.ai/docs/simulation/cli.md#exit-codes) into the check and the comment:

| What happened | CLI exit | Check | Pull request comment |
| - | - | - | - |
| Every Scenario passed | `0` | Pass | The totals and a link to the run. |
| A Scenario failed | `1` | Fail | Every Scenario with its result. Failed ones add their failed evals and a call link. |
| A setup problem | `2` | Fail | The reason and what to fix. |
| Tuner couldn't finish | `3` | Pass with a warning. Fail when `fail-on-tuner-error` is `true`. | The reason, and that the build wasn't blocked. |
| The job was stopped | `130` or `143` | The job shows as cancelled. | Not updated. |

### The job summary

The job summary has a title, such as "Tuner simulations: all 12 passed", and a link to the run in Tuner. A failed run adds a table of its Scenarios and their results, up to 1,000 rows.

### The pull request comment

On pull request events the Action posts one comment for each agent and updates it on every push. It has the same content as the job summary, with up to 50 Scenario rows. When there are more than 50, failed ones come first and the table ends with "and N more".

![The Action's pull request comment on a failed run: the title "Tuner simulations: 2 of 4 failed", a table of four Scenarios with their results, the failed evals human\_transfer and sms\_confirmation\_sent with View call links, and an Open run in Tuner link](https://mintcdn.com/tuner/1Z9ktZs-JSYRgGHw/images/simulation/ci-cd-comment-scenarios-failed.png?fit=max\&auto=format\&n=1Z9ktZs-JSYRgGHw\&q=85\&s=a50669ab8464ea166beac4db62c96292)

Failed rows add the failed eval names and a **View call** link. A passed run shows only a title and a link to the run:

![The Action's pull request comment on a passed run: the title "Tuner simulations: all 2 passed" and an Open run in Tuner link](https://mintcdn.com/tuner/1Z9ktZs-JSYRgGHw/images/simulation/ci-cd-comment-all-passed.png?fit=max\&auto=format\&n=1Z9ktZs-JSYRgGHw\&q=85\&s=bebe30b92a71eebb91a83f327a8c7a3d)

The Action skips the comment in two cases. The check and the job summary still appear.

* With a warning, when the workflow lacks `pull-requests: write` or the pull request comes from a fork.
* With a notice, when the pull request has a newer commit than the one the run tested.

> [!NOTE]
>
> The job summary and the comment show Scenario names, results and failed eval names only. Transcripts, audio and eval reasoning never reach GitHub.

## Run metadata

The Action sends four metadata keys with the run, so the run shows which commit it tested. See [See which commit a run tested](https://docs.usetuner.ai/docs/simulation/run-statuses.md#see-which-commit-a-run-tested).

| Key | Value |
| - | - |
| `commit` | The commit SHA. On pull requests, the head commit of the pull request, not the merge commit. |
| `branch` | The pull request's head branch, or the branch you pushed. |
| `pr_url` | The pull request's URL. Left out when there's no pull request. |
| `repo_url` | The repository's URL. |

Add your own keys with the `meta` input, one `key=value` pair per line. A key that matches one above overrides it.

```yaml theme={null}
meta: |
  env=staging
  release=2026-11
```

## Troubleshooting

> [accordion] No Tuner API key provided
>
> The Action found no key. Add `TUNER_API_KEY` as a repository secret and pass it as `api-key`. Pull requests from forks get no secrets, so skip them with the `if:` lines above.

> [accordion] Couldn't post the PR comment
>
> Add `pull-requests: write` under `permissions:` in the workflow.

> [accordion] The check passed with a warning
>
> Tuner couldn't finish the run, so the Action didn't block your build. The warning names the reason. To fail the check in this case, set `fail-on-tuner-error: true`.

> [accordion] The agent already has a run in progress
>
> Another workflow is testing the same agent. Add the `concurrency` group from the workflows above, or wait for the other run to finish.

> [accordion] The run is still going after I canceled the job
>
> The Action passes the job's stop signal to the CLI, which cancels the run. If a run is left behind, see [Cancel a run](https://docs.usetuner.ai/docs/simulation/cli.md#cancel-a-run).

## Inputs

| Input | Required | Description |
| - | - | - |
| `api-key` | Yes | Your Tuner API key. Store it as a repository secret. |
| `agent` | Yes, unless `TUNER_AGENT_ID` is set | The agent to test. Falls back to the `TUNER_AGENT_ID` environment variable. |
| `tag` | One of `tag` or `scenario` | Runs the agent's Scenarios with this tag. |
| `scenario` | One of `tag` or `scenario` | Scenario IDs to run, comma-separated. |
| `language` | No | The caller language, a code such as `en-US` or the full name. |
| `profile` | No | A test profile name. |
| `noise` | No | A background noise slug. |
| `noise-intensity` | No | `low`, `medium` or `high`. |
| `timeout` | No | Cancels the run after this long, for example `30m`. The default is `60m`. Keep the job's `timeout-minutes` above it. |
| `fail-on-tuner-error` | No | Fails the check when Tuner couldn't finish the run. The default is `false`, which passes with a warning. |
| `meta` | No | Extra run metadata, one `key=value` pair per line. |
| `comment` | No | Posts or updates the pull request comment. The default is `true`. |
| `github-token` | No | The token used only for the pull request comment. Defaults to the workflow's token. |

Set `tag` or `scenario`, not both. For the language, noise and test profile values, see [Set the language, noise and test profile](https://docs.usetuner.ai/docs/simulation/cli.md#set-the-language-noise-and-test-profile).

## Outputs

Give the step an `id` to read its outputs in a later step, as in `steps.tuner.outputs.run-url`.

| Output | Description |
| - | - |
| `run-id` | The Tuner run ID. |
| `run-url` | The link to the run in Tuner. |
| `result` | The run result, such as `passed` or `failed`. |
| `reason` | Why the run didn't pass, such as `agent_failed`, `timeout` or an error code. |
| `exit-code` | The Tuner CLI exit code. |
| `total` | The number of Scenarios. |
| `passed` | The Scenarios that passed. |
| `failed` | The Scenarios that failed. |

## Limits

| Limit | Value |
| - | - |
| Default `timeout` | 60 minutes |
| Rows in the pull request comment | 50 |
| Rows in the job summary | 1,000 |
| Scenarios per run | Up to 100 |

## Next steps

> [card] [Other CI tools](https://docs.usetuner.ai/docs/simulation/ci/other-tools.md)
>
> Run the CLI in GitLab CI, CircleCI, Jenkins or any other pipeline.

> [card] [CLI](https://docs.usetuner.ai/docs/simulation/cli.md)
>
> Exit codes, JSON output and every command the Action runs for you.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.