﻿---
title: GitHub Action
description: nullean/silk is a GitHub Action: it installs silk, runs a suite with --junit, uploads the results and fails the job when a scenario fails. It does not...
url: https://docs-v3-preview.elastic.dev/workflow/github-action
---

# GitHub Action
`nullean/silk` is a GitHub Action: it installs silk, runs a suite with `--junit`, uploads the results and fails the job when a
scenario fails. It does **not** install an agent or log in to one: do that in a step before it, because it differs for each agent.
```yaml
jobs:
  evaluate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
        with:
          persist-credentials: false
      - run: npm install --global @anthropic-ai/claude-code@2.1.334
      - uses: nullean/silk@v0.2        # see "Which ref" below
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        with:
          suite: suites/my-mcp.silk.yaml
          trials: 3
          max-cost-usd: 5
```

In GitHub Actions silk also prints an `::error` annotation per failed scenario and writes the report to the job's step summary; see
[In CI](/workflow/ci#reports-for-ci-systems).

## Short-lived credentials instead of an API key

Anthropic workload identity federation lets the job trade its GitHub OIDC token for a short-lived Anthropic token, so no
`ANTHROPIC_API_KEY` is stored. silk's own `live.yml` runs this way against the real `claude` CLI (2.1.334): the agent and the judge both
authenticate through it, and the example suite passed.
```yaml
    permissions:
      id-token: write
    env:
      ANTHROPIC_FEDERATION_RULE_ID: fdrl_...
      ANTHROPIC_ORGANIZATION_ID: ...
      ANTHROPIC_SERVICE_ACCOUNT_ID: svac_...
      ANTHROPIC_WORKSPACE_ID: wrkspc_...
      ANTHROPIC_IDENTITY_TOKEN_FILE: /tmp/anthropic-identity-token
    steps:
      - name: Fetch the GitHub OIDC token
        run: |
          set -euo pipefail
          jwt=$(curl -sSf -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
            "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://api.anthropic.com" | jq -r '.value')
          echo "::add-mask::$jwt"
          umask 077
          printf '%s' "$jwt" > "$ANTHROPIC_IDENTITY_TOKEN_FILE"
```

- **Set up the rule in the Claude Console** (an organization admin; Workload identity, Connect workload, GitHub Actions). The IDs are
  identifiers, not secrets.
- **No other credential may be set.** `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, an `apiKeyHelper` or `CLAUDE_CODE_OAUTH_TOKEN` takes
  precedence over the federation, and `claude --bare` ignores it.
- **Match the token's real claims.** If your organization uses GitHub's immutable subject format, the `sub` claim is
  `repo:<owner>@<id>/<repo>@<id>:ref:refs/heads/main`, not `repo:<owner>/<repo>:...`, and a rule written from the plain form is denied
  with `match_subject_prefix`. Print the claims (never the token) to see them, and read the deny reason under the Console's
  authentication history. Constrain the rule with `repository`, `repository_owner`, `ref` or `job_workflow_ref` claims, not only a
  prefix; a rule that does not pin the repository and branch would also accept pull requests from forks.
- **Not verified:** the rule above was exercised only by a manual run on the default branch. A single run's token is exchanged more than
  once (the agent and the judge each exchange it); that worked here, but the exchange is documented as single use per token, so a long
  suite that outlives the token should be tested before you rely on it.


## Which ref

- **From 0.2.0.** The action was added after `0.1.0`, so `nullean/silk@0.1.0` has no `action.yml`; use `0.2.0` or later.
- **An exact tag** (`nullean/silk@0.2.0`) installs exactly that silk, so an eval run is reproducible. A floating tag
  (`nullean/silk@v0.2`) follows the 0.2.x patches and installs the latest silk. While silk is 0.x a breaking change bumps the minor
  version, so the floating tag is `v0.<minor>`, never `v0`; from 1.0 it is `v<major>`.
- A branch or a SHA installs the latest released silk, since neither names a version. Set `version` to pin it.


## Inputs


| Input                                                | Default                          | Meaning                                                                                                     |
|------------------------------------------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------|
| `suite`                                              | required                         | The suite file, relative to `working-directory`.                                                            |
| `agent`                                              | `claude`                         | `claude`, `codex`, `cursor`, `copilot`, `gemini` or `opencode`. It must be installed and logged in already. |
| `trials`, `arm`, `scenario`, `judge`, `max-cost-usd` | empty                            | Passed to `silk run` as `--trials`, `--arm`, `--scenario`, `--judge`, `--max-cost-usd` when set.            |
| `args`                                               | empty                            | Extra arguments for `silk run`, split on spaces.                                                            |
| `version`                                            | the ref's version, or the latest | The silk version to install.                                                                                |
| `working-directory`                                  | `.`                              | Where the suite is, and where relative paths start.                                                         |
| `junit`                                              | `.silk-ci/results.xml`           | Where the JUnit XML goes.                                                                                   |
| `output`                                             | `.silk-ci/run`                   | Where the run folder (`report.md`, transcripts) goes.                                                       |
| `upload`                                             | `true`                           | Upload the JUnit file and the run folder as an artifact, whether or not the run passed.                     |
| `artifact-name`, `retention-days`                    | `silk-results`, `14`             | The artifact's name and how long it lives.                                                                  |


## Outputs

`exit-code` is silk's own (0 all passed, 1 a scenario failed, 2 usage, 3 an agent run or a report write failed), `junit` and
`run-directory` are the paths above. The results are uploaded before the job fails, so a failing run still leaves its report.

## What was verified

The action's scripts (`build/action-version.sh`, `build/action-run.sh`) have offline tests against a fake silk, mutation-checked, and run
in CI on Linux and Windows; the action file is linted with zizmor. The repository's `live` workflow runs it on demand against the real
`claude` CLI with the credential-free `examples/hello` suite. **Not verified:** a run on a Windows or macOS runner (the Windows tool shim is
handled but untried), and any agent other than `claude` through the action.