> For the complete documentation index, see [llms.txt](https://docs.getantidote.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getantidote.com/welcome-to-antidote/integrations/github-actions/quickstart-preview-action.md). Agents can also search and read this documentation through its [MCP server](https://docs.getantidote.com/~gitbook/mcp).

# Quickstart: preview action

Start Antidote automatically for pull request previews.

{% hint style="warning" %}
Install the Antidote GitHub App and link it to your Antidote organisation. An org admin opens **Settings → Integrations**, selects **Connect** on the **GitHub** card under **Source control & CI/CD** and selects **Install on GitHub**. If the App is already installed on your GitHub organisation, select **Link existing install** instead. An App installed straight from GitHub is not linked, and Antidote posts no PR comments or check runs until it is. Antidote reads the pull request through the App so it can test it, and the App posts the PR comment and check run. Without it, the pull request is not tested and the step logs what to fix.
{% endhint %}

Use this workflow when each pull request gets its own preview deployment. The workflow records each pull request's preview build, and a comment on the pull request asks Antidote to test it.

{% stepper %}
{% step %}

### 1. Add Preview deployments to the product

Before the first run, an org admin opens **Product settings** (the cog next to the product menu), goes to **Environments**, selects **Add environment**, sets **Type** to **Preview deployments** and selects **Create**. All pull-request previews share this one slot. Until it exists, the preview action stops with "Add Preview deployments in Product settings → Environments before using the preview action."
{% endstep %}

{% step %}

### 2. Add the required repository secret and variable

Create `PLATFORM_API_KEY` in the Antidote dashboard under **Settings → API keys**.

Add `PLATFORM_PRODUCT_ID` as a repository variable. It is not a secret.
{% endstep %}

{% step %}

### 3. Create the workflow file

Copy this file into `.github/workflows/duku-preview.yml`:

```yaml
name: Duku preview

on:
  pull_request:
    types: [opened, synchronize, reopened]
    branches: [main]

concurrency:
  group: duku-preview-${{ github.event.pull_request.number }}
  cancel-in-progress: true

jobs:
  preview:
    name: Duku preview
    runs-on: ubuntu-latest
    # The action exits in seconds; this cap only guards against network hangs.
    timeout-minutes: 5
    permissions:
      contents: read
      pull-requests: read    # for preview URL resolution
      deployments: read      # required for preview URL resolution
      checks: read           # for preview URL resolution
      statuses: read         # for preview URL resolution
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - name: Duku preview
        id: preview
        uses: duku-ai/actions/preview@preview/v1
        with:
          api-key: ${{ secrets.PLATFORM_API_KEY }}
          product-id: ${{ vars.PLATFORM_PRODUCT_ID }}
          # Optional: bypass Vercel Deployment Protection on protected previews.
          # vercel-automation-bypass-secret: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
```

{% endstep %}

{% step %}

### 4. Update the workflow values

* `branches: [main]` should match the branch you merge into.
* `api-key` reads the repository secret `PLATFORM_API_KEY`.
* `product-id` reads the repository variable `PLATFORM_PRODUCT_ID`.

The action finds the PR's preview URL with the job's own GitHub token. The read permissions above are all it needs: the Antidote GitHub App posts the PR comment.

`deployments: read`, `checks: read`, and `statuses: read` let the action resolve the preview URL. `actions/setup-node` gives the runner Node 22, which the action needs.
{% endstep %}

{% step %}

### 5. Open a pull request and comment `@antidoteapp`

The workflow resolves the preview URL, records the pull request's build, and exits within seconds.

To test the pull request, anyone with write access to the repository comments `@antidoteapp` on it. Antidote reacts with 👀 and starts the test. If the build is not recorded yet, Antidote replies that it is waiting and tests the build once it arrives.

The Antidote GitHub App posts one comment while Antidote tests the pull request, then updates it with each thing Antidote tried, whether it worked, and any issues the pull request may have caused. It also concludes the `Duku Exploration (<product name>)` check run. The check is still named Duku Exploration, so your branch protection rules keep working.

Each comment tests the build Antidote has for the pull request at that moment. After a new push, comment `@antidoteapp` again to test the new build. When a pull request has builds of several products, add a product name after the handle, such as `@antidoteapp Web App`, to test only that product.

The `concurrency` block cancels superseded runs for the same pull request.
{% endstep %}
{% endstepper %}

PRs opened from forks cannot read repository secrets. Antidote previews require a PR from a branch in the same repository.

### Preview URL resolution

On a pull request, the `preview` action figures out which deployed URL to explore.

With `preview-url-source: auto`, it checks the PR head commit's GitHub Deployments, then Checks (when `preview-check-name-regex` is set), then Statuses (when `preview-status-context-regex` is set). `auto` never reads PR comments.

You can force a single source. You can also set `exploration-url` to skip resolution entirely.

{% hint style="info" %}
`wait-for-target-seconds` and `credential-set` apply to runs outside a pull request.
{% endhint %}

#### Example: resolve the URL from Vercel comments

```yaml
- uses: duku-ai/actions/preview@preview/v1
  with:
    api-key: ${{ secrets.PLATFORM_API_KEY }}
    product-id: ${{ vars.PLATFORM_PRODUCT_ID }}
    preview-url-source: 'comments'
    preview-comment-author-logins: 'vercel[bot]'
```

`auto` is usually the right choice. Use `comments` when your deployment provider does not publish a usable GitHub Deployment.

When no source returns a URL, the run uses the product's base URL and the step logs "Preview URL not found; falling back to subject baseUrl."

### Android apps

For an Android app, pass the pull request's APK with `apk-path` instead of a preview URL. Antidote tests each upload on the product's primary device, with no comment needed. See [Upload builds from CI](https://docs.getantidote.com/welcome-to-antidote/android-apps/upload-builds-from-ci.md).

### Read next

* [Choosing preview vs environment](https://docs.getantidote.com/welcome-to-antidote/integrations/github-actions/choosing-preview-vs-environment.md)
* [Configuration reference](https://docs.getantidote.com/welcome-to-antidote/integrations/github-actions/configuration-reference.md)
* [Troubleshooting](https://docs.getantidote.com/welcome-to-antidote/integrations/github-actions/troubleshooting.md)
