> 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-environment-action.md). Agents can also search and read this documentation through its [MCP server](https://docs.getantidote.com/~gitbook/mcp).

# Quickstart: environment action

Start Antidote automatically for stable environments.

Use this workflow for an environment you declare in the Antidote dashboard, such as staging or a production canary. For a pull request's preview, use the [Quickstart: preview action](https://docs.getantidote.com/welcome-to-antidote/integrations/github-actions/quickstart-preview-action.md).

{% stepper %}
{% step %}

### 1. Declare the environment in the Antidote dashboard

Open the product in the Antidote dashboard and go to **Product settings → Environments**. Add the environment with its name and URL, such as `staging`. New products start with a production environment.

Store the product ID as the repository variable `PLATFORM_PRODUCT_ID`.
{% endstep %}

{% step %}

### 2. Add the repository secret

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

Store it as the repository secret `PLATFORM_API_KEY`.
{% endstep %}

{% step %}

### 3. Create the workflow file

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

```yaml
name: Duku environment

on:
  push:
    branches: [main]
  workflow_dispatch:

concurrency:
  group: duku-env-staging
  cancel-in-progress: false

jobs:
  explore:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: duku-ai/actions/environment@environment/v1
        with:
          api-key: ${{ secrets.PLATFORM_API_KEY }}
          product-id: ${{ vars.PLATFORM_PRODUCT_ID }}
          environment: staging
```

{% endstep %}

{% step %}

### 4. Update the workflow values

* `branches: [main]` should match the branch that deploys this environment.
* `environment` names the environment you declared. Leave it out to use the product's default environment.
* Each push is recorded as a release on that environment, named from `git describe`. Pass `release-label` to use your own name.
* With the Antidote GitHub App installed and linked, Antidote links each merged pull request to the release it shipped in.
* `actions/setup-node` gives the runner Node 22, which the action needs.

Antidote runs against the URL the environment declares. Each push runs your flows on the new release and queues an exploration of it; while the product has no flows, the run is an exploration. The step's `run-id` output is the ID of that run.

`cancel-in-progress: false` lets a running step finish before the next push's starts. GitHub keeps only the newest waiting run, so pushes in between are skipped, and an exploration still waiting moves to the newest release. Set it to `true` if you would rather drop earlier in flight runs.
{% endstep %}
{% endstepper %}

#### Wait for the deploy

On a fresh push the environment may still serve the previous build for a minute. Set `wait-for-deployment: true` and the action waits until the environment serves the pushed commit before it records anything.

```yaml
wait-for-deployment: true
wait-commit-header: x-commit-sha
```

Your app must return its deployed commit in that header. On Vercel, set it from `VERCEL_GIT_COMMIT_SHA` in `next.config.js` headers. The wait applies to `push` runs, and to scheduled and manual runs that pass `commit`. Other runs start straight away.

### Nightly health checks

A scheduled workflow is a good fit for nightly health checks against staging.

```yaml
name: Duku nightly staging

on:
  schedule:
    - cron: '0 3 * * *'
  workflow_dispatch:

jobs:
  explore:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: duku-ai/actions/environment@environment/v1
        with:
          api-key: ${{ secrets.PLATFORM_API_KEY }}
          product-id: ${{ vars.PLATFORM_PRODUCT_ID }}
          environment: staging
```

The checkout lets the run name the release the same way your push workflow did, so the nightly run reuses that release.

To run against a release you name, for example when the deployed build is not the commit the workflow runs on, pass it as `release-label`:

```yaml
on:
  workflow_dispatch:
    inputs:
      release:
        required: true
# ...
        with:
          api-key: ${{ secrets.PLATFORM_API_KEY }}
          product-id: ${{ vars.PLATFORM_PRODUCT_ID }}
          environment: staging
          release-label: ${{ inputs.release }}
          release-label-from: input
```

A new label records a new release and makes it the one that environment serves. Sending the same label again records nothing new, and the run explores whatever the environment serves at that moment.

### Keeping Antidote in step with your releases

Run the environment action as the step after each deploy, once per environment, with `environment:` set to the environment you just deployed to (for example `staging` in your staging workflow and `production` in your production workflow). Keep `wait-for-deployment` on so Antidote tests the new build, not the one it replaced.

* **One commit is one release.** Promoting the same commit from staging to production records one release deployed to two environments, so its results sit together on the release page.
* **Redeploys and rollbacks** reuse the existing release. Deploying an older commit again makes that release **Live** on the environment once more and marks it **Redeployed**.
* **Release names** come from `git describe` by default, so check out with `fetch-depth: 0` and a tagged commit is named after its tag. To use your own name, pass `release-label`. See [Release names](https://docs.getantidote.com/welcome-to-antidote/integrations/github-actions/configuration-reference.md#release-names).

### Android apps

For an Android app, pass each build's APK with `apk-path`. 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)
