# GitHub Actions

Source: https://docs.autessa.com/docs/integrations/github-actions

> Attack-test and grade your AI agent on every pull request with the Autessa eval action, and deploy to one or many tenants with the Autessa CDK and the deploy action.

# GitHub Actions

(Preview)

These actions are in private preview. Names are final; details may change before release.

Two actions. The eval action runs the Autessa attack simulator and transcript grading against your agent, posts a scorecard on the pull request, and fails the check below your thresholds. The deploy action previews and deploys an Autessa CDK project to your stages.

Both actions declare the `node20` runtime. GitHub may run them on a newer Node version.

## Install

Add a workflow file to `.github/workflows/`. Store your keys as secrets: `AUTESSA_API_KEY` for evals (a developer key from [Get a free API key](https://builder.autessa.com/get-api-key) works). For deploys, use two deploy keys per stage: one with only **Preview changes** for pull requests, as a repository secret, and one with **Preview changes** and **Deploy** for merges, as a secret in a GitHub environment. See [Keys](/docs/start/keys.md).

## Minimal example: evals

```yaml
name: Autessa eval
on: pull_request
permissions:
  contents: read
  pull-requests: write
jobs:
  eval:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Autessa-Inc/autessa-eval-action@v0
        with:
          api-key: ${{ secrets.AUTESSA_API_KEY }}
          agent-id: agt_your_agent_id
          categories: PROMPT_INJECTION,SOCIAL_ENGINEERING,DISCLOSURE_PROBING
          golden-conversations: evals/golden.jsonl
          min-block-rate: "0.9"
          min-grade-pass-rate: "0.9"
```

The action posts a scorecard comment on the pull request and updates the same comment on every push. The same summary appears on the run's summary page.

### Your own endpoint

(Preview)

To attack your own agent over HTTP instead of an Autessa agent, set `target-url`. The simulator sends each attack as a POST, filling in `{{message}}` and `{{sessionId}}`, then reads the reply with a JSONPath. Header values are the names of Autessa secrets, never the values themselves:

```yaml
      - uses: Autessa-Inc/autessa-eval-action@v0
        with:
          api-key: ${{ secrets.AUTESSA_API_KEY }}
          target-url: https://staging-agent.example.com/chat
          target-request-template: '{"message": "{{message}}", "sessionId": "{{sessionId}}"}'
          target-response-path: $.reply
          target-headers: '{"Authorization": "staging-agent-token"}'
          target-multi-turn: "true"
          languages: en,es
          min-block-rate: "0.9"
```

Multi-turn attacks (`target-multi-turn`) and attack languages (`languages`) are also in preview.

## Minimal example: deploy

(Preview)

```yaml
# .github/workflows/autessa-deploy.yml
name: Autessa deploy
on:
  pull_request:
  push:
    branches: [main]
permissions:
  contents: read

jobs:
  # Pull requests: preview only, with "Preview changes" keys (repository secrets).
  preview:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    concurrency:
      group: autessa-preview-${{ github.ref }}
      cancel-in-progress: true
    env:
      AUTESSA_DEPLOY_KEY_DEV: ${{ secrets.AUTESSA_PREVIEW_KEY_DEV }}
      AUTESSA_DEPLOY_KEY_PROD: ${{ secrets.AUTESSA_PREVIEW_KEY_PROD }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 24 }
      - run: npm ci   # only needed for autessa.config.ts projects
      - uses: Autessa-Inc/autessa-deploy-action@v0
        with:
          command: diff
          stages: dev,prod

  # Merges to main: deploy each stage with its "Deploy" key, kept in a GitHub environment.
  deploy-dev:
    if: github.event_name == 'push'
    runs-on: ubuntu-latest
    environment: dev
    concurrency:
      group: autessa-deploy-dev
      cancel-in-progress: false
    env:
      AUTESSA_DEPLOY_KEY_DEV: ${{ secrets.AUTESSA_DEPLOY_KEY_DEV }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 24 }
      - run: npm ci
      - uses: Autessa-Inc/autessa-deploy-action@v0
        with:
          command: deploy
          stages: dev

  deploy-prod:
    needs: deploy-dev
    runs-on: ubuntu-latest
    environment: production
    concurrency:
      group: autessa-deploy-prod
      cancel-in-progress: false
    env:
      AUTESSA_DEPLOY_KEY_PROD: ${{ secrets.AUTESSA_DEPLOY_KEY_PROD }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 24 }
      - run: npm ci
      - uses: Autessa-Inc/autessa-deploy-action@v0
        with:
          command: deploy
          stages: prod
```

Pull requests get a diff comment, run with preview-only keys. Merges deploy `dev`, then `prod`, with deploy keys kept in GitHub environments. If a stage fails, the run stops there. Each stage reads its key from the env variable named by `deployKeyEnv` in `autessa.stages.yaml`, falling back to `deploy-key`, then `AUTESSA_DEPLOY_KEY`.

## How it works

- **Eval action:** starts an attack simulation against an Autessa agent, a firewall policy, or your own endpoint, and grades your golden conversations. It writes the scorecard to `autessa-scorecard.json` and posts a markdown summary.
- **Thresholds:** the check fails if the block rate or the grade pass rate is below your minimum. The block rate counts blocked attacks only; flagged attacks are shown but do not count as blocked.
- **Attack categories:** `PROMPT_INJECTION`, `SOCIAL_ENGINEERING`, `PASSPHRASE_GUESSING`, `WORD_OF_DAY_REPLAY`, `ANOMALY`, `DISCLOSURE_PROBING`, `CLONED_VOICE`. Categories the target can't run, such as voice attacks against a text endpoint, are listed as not available and left out of the rate.
- **Golden conversations:** a `.json` or `.jsonl` file, or a folder of them. Turn roles are `USER`, `ASSISTANT`, `TOOL_CALL`, and `TOOL_RESULT`, with an `expectedOutcome` for each conversation.
- **Deploy action:** runs the same engine as `npx autessa-cdk` on a project written as `autessa.config.ts` or `autessa.yaml`, or the Maven or Gradle plugin on a Java project. The diff marks any change that gives someone more access as **WIDENS ACCESS**. `deploy` applies the change.

## Options

Eval action:

| Input | What it does |
| --- | --- |
| `api-key` | Your Autessa API key. Required. Masked in logs. |
| `agent-id` | Attack this Autessa agent. |
| `policy-name` | Attack this firewall policy, or apply it when attacking an agent or endpoint. |
| `target-url` | Attack your own HTTP endpoint (POST). Use instead of `agent-id`. Preview. |
| `target-request-template`, `target-response-path`, `target-headers` | How to call your endpoint and read its reply. Preview. |
| `target-multi-turn` | Run multi-turn attacks. Preview. |
| `categories` | Comma-separated attack categories. Default: all. |
| `languages` | Comma-separated attack languages, for example `en,es`. Preview. |
| `golden-conversations` | Path to transcripts to grade. |
| `min-block-rate`, `min-grade-pass-rate` | Fail thresholds from 0 to 1. |
| `comment-on-pr` | Post or update the scorecard comment. Default `true`. Needs `pull-requests: write`. |
| `github-token`, `base-url`, `timeout-minutes` | Comment token, API URL override, and how long to wait (default 30). |

Outputs: `scorecard`, `scorecard-path`, `summary`, `block-rate`, `grade-pass-rate`, and `passed`.

Deploy action:

| Input | What it does |
| --- | --- |
| `command` | `diff` (default) previews; `deploy` applies. |
| `stages` | Comma-separated stages from `autessa.stages.yaml`, run in order. |
| `fanout` | Comma-separated fanout groups. Each runs against every tenant in the group. |
| `deploy-key` | A key for any stage whose `deployKeyEnv` variable is not set. |
| `working-directory` | The folder with the project. Default `.`. |
| `build-tool` | `auto` (default), `node`, `maven` or `gradle`. |
| `prune` | When deploying, also delete resources removed from the project. |
| `allow-widen`, `allow-purchase`, `adopt`, `allow-destructive` | Let a deploy apply changes that widen access, cost money, take over existing resources, or drop columns. Without them, such a deploy stops after the preview. |
| `fail-on-widen` | Fail the `diff` check when any change widens access. |
| `skip-build` | Don't build app folders. |
| `comment-on-pr` | Post or update the PR comment. Default `true`. |

Outputs: `summary`, `changes`, `widens`, `purchases`, `deployment-ids`, `passed`, `reason` and `exit-code`. See the [deploy action](/docs/cdk/deploy-action.md) page for details. Deploys from the action show on the company's Deployments page in Autessa with the repository, the commit and a link to the run.

## Example

[ci-eval-before-release](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/ci-eval-before-release): attack-test an agent's endpoint on every pull request. The weak agent fails the check, and the same agent with the Autessa firewall passes.

## Related

- [Evaluations and attack simulator](/docs/features/evaluations.md)
- [Deploy action](/docs/cdk/deploy-action.md)
- [Autessa CDK](/docs/cdk.md)
- [Evaluations API](/docs/reference/evaluations.md)
- [Deploy API](/docs/reference/deploy.md)

