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

# Move GitHub Actions jobs to Trunk Runners

You are helping a user move a repository's GitHub Actions jobs from the runners they use today (GitHub-hosted, self-hosted or another vendor's) to Trunk Runners. A job moves by changing one line, its `runs-on` label. Trunk then starts a fresh VM for the job and removes it when the job ends. Aim to do the whole move from this one prompt and finish with an open pull request. The user confirms access and answers a few questions. You do the rest.

The `app.trunk.io` links in this file open the user's own Trunk organization once they are signed in, so give them to the user and do not fetch them yourself. If the user's prompt names their organization, put its slug first in the path: `app.trunk.io/<org>/runners`.

The docs links in this file already end in `.md`, so open them as they are. The full index is at [docs.trunk.io/llms.txt](https://docs.trunk.io/llms.txt).

## Before you start

* **Reply first.** Your first message is the step 1 questions. Before it, read only `.github/workflows/` and the files those workflows call, so you can fill in your best guesses. Do not open docs or edit anything yet.
* **Open docs only when a step needs them.** Do not read ahead.
* **Know where you run.**
  * With the repository and a terminal (Claude Code, Cursor, Codex): follow every step.
  * In a chat app without the repository: ask the user to paste their workflows, then return the edited files and the pull request description for them to apply.
* **Trunk Runners run x86-64 Linux jobs only, for now.** macOS, Windows and ARM jobs stay on the runners they have. Say this with the step 1 questions when the repository has such jobs.
* **A wrong label fails without an error.** A `trunk=` label that Trunk cannot read, or one in an organization that is not connected, gets no runner: the job stays queued and nothing says why. So the pull request is not safe to merge until its own run shows the Trunk jobs starting (step 8).
* **The user may prefer the Trunk app.** [Runners → Migrate](https://app.trunk.io/runners/migrate) scans repositories and opens the same kind of pull request with no agent. Mention it once. Continue here if they want a shadow run, or want you to make the edits.

## 1. Ask what they want

Ask these in one message. Fill in your best guess from the workflows, so the user can reply "ok" or change a value.

1. **Shadow or replace?** Explain both in a line each, and recommend one.
   * **Shadow.** You add a new workflow file beside each chosen workflow. It holds a copy of the chosen jobs that runs on Trunk Runners, on the same pushes and pull requests. The existing files do not change, the copies are not required checks, and removing the shadow is deleting those files. After some days of runs they compare the two, then cut over in a second pull request. They pay for both runners while it lasts.
   * **Replace.** Each chosen job moves to Trunk Runners in this pull request. One change, and nothing to clean up later.
   * Recommend **shadow** when jobs run on self-hosted runners, lean on tools the current image installs, or reach a private network, and when the user wants timings before they decide. Recommend **replace** for plain jobs on GitHub-hosted Linux runners.
2. **Which jobs?** Show a table of every job: its workflow, its `runs-on` today, and the Trunk label you would give it (step 2). List the jobs you would leave alone, with one reason each (step 3). For a shadow, suggest the few jobs that run longest or most often, not all of them.
3. **Machines you cannot size.** For each self-hosted or custom label whose CPU count you cannot read from the repository, ask what the machine is.
4. **Access.** Trunk Runners is in private beta. Ask the user to confirm each item.
   * Trunk Runners is turned on for their Trunk organization: [Runners](https://app.trunk.io/runners) opens for them. If it shows a request for access, they send it from that page, or write to [support@trunk.io](mailto:support@trunk.io).
   * The Trunk and Trunk Runners GitHub Apps are installed on the GitHub organization, with access to this repository: [GitHub Connections](https://app.trunk.io/settings/organization/github).

If the repository is public, say so with the questions: GitHub-hosted runners cost nothing there, and Trunk Runners are billed. See [Pricing](https://docs.trunk.io/runners/pricing.md).

## 2. Map each runner to a Trunk machine

Give each job the size with the CPUs it has now. Name only the `size` and leave `memory` out: Trunk gives the size its standard memory, and most jobs do not need more. Do not change a job's CPU count in this pull request: a move that also changes the CPUs hides which change caused a difference.

| Runner today | Trunk label options |
| - | - |
| `ubuntu-latest`, `ubuntu-24.04`, `ubuntu-22.04` in a private repository | none (2 CPUs) |
| The same labels in a public repository (4 CPUs) | `size=medium` |
| 4 CPUs | `size=medium` |
| 8 CPUs | `size=large` |
| 16 CPUs | `size=xlarge` |

* **Another vendor's label** usually names its CPU count (`...-4vcpu-...`, `...-8-cores`, `...-standard-4`). Match the CPUs with `size`.
* **A GitHub larger runner** has a name the organization chose. Read the CPU count from the name if it is there. Otherwise ask.
* **A self-hosted label** (`self-hosted`, a runner group, an Actions Runner Controller scale set) says nothing about the machine. Use the answer to question 3.
* **More than 16 CPUs** has no Trunk size. Leave the job and list it.

See [Machine sizes](https://docs.trunk.io/runners/actions/sizes.md) for every size. A job on 2 CPUs gets no options, not `size=small`: the label with no options is the 2-CPU machine of GitHub's `ubuntu-latest`. A job that runs out of memory after the move is a difference from step 7.

## 3. Choose the jobs

Trunk Runners currently support only Linux jobs on x86-64. Move a job when it is one of those and you can name its machine. Leave these alone, and list each in the pull request with its reason:

* **macOS, Windows and ARM jobs.** Trunk Runners do not support them yet. Do not move or shadow one: it would get no runner, or fail on the wrong architecture. A workflow can mix runners, so its Linux x86-64 jobs still move.
* **GPU jobs.** No Trunk size has a GPU.
* **A job that needs its machine's network or identity.** A self-hosted job that reaches a private database or registry, sits behind an IP allowlist, or takes cloud credentials from the machine. It would start on Trunk and then fail.
* **A job that needs state left on its machine.** A warm Docker layer cache, a checkout or a tool directory that a long-lived self-hosted runner keeps between runs. A Trunk runner starts fresh.
* **A job you cannot size** after question 3.

A job is fine to move when it runs in a `container:`, uses `services:`, runs a matrix, or is called as a reusable workflow. For a self-hosted job you are unsure of, prefer a shadow to leaving it out: the copy shows what breaks at no risk.

## 4. Write the label

```yaml theme={"system"}
runs-on: trunk=${{ github.run_id }}-${{ github.run_attempt }}..size=large
```

* **Start with `trunk=${{ github.run_id }}-${{ github.run_attempt }}`,** exactly. It keeps a job from another workflow run from taking this run's runner.
* **Add the size as `..size=<size>`,** the one option. Leave it out for a 2-CPU job.
* **The label is the only label.** Replace a list such as `[self-hosted, linux, x64]` with the one string.
* **Use only values the docs list.** An unknown value, such as `size=huge`, gets no runner.
* **Do not add `template` or `cache`** in this pull request. A job with no `template` uses the organization's default template, and `actions/cache` uses Trunk's shared cache with no workflow change.

Inside an expression, build the label with `format`:

```yaml theme={"system"}
runs-on: ${{ format('trunk={0}-{1}..size=large', github.run_id, github.run_attempt) }}
```

**A matrix that sets the runner** (`runs-on: ${{ matrix.os }}`): do not change the matrix value. It is part of each job's name, and a name with a run ID in it changes on every run. Map the value where it is read:

```yaml theme={"system"}
runs-on: >-
  ${{ matrix.os == 'ubuntu-latest'
    && format('trunk={0}-{1}', github.run_id, github.run_attempt)
    || matrix.os }}
```

**A reusable workflow** has its `runs-on` in the called file. Edit it there, and tell the user that every workflow calling that file moves with it. If the label is an input, change the value the callers pass.

See [The runs-on label](https://docs.trunk.io/runners/actions/runs-on.md) and the [label reference](https://docs.trunk.io/runners/reference/runs-on-grammar.md).

## 5. Replace

Change the `runs-on` value of each chosen job. Make no other edit: do not rename jobs, change job keys, change triggers, bump actions or reformat the file. Job names stay the same, so required checks need no change.

To undo a replace, the user reverts the pull request. Do not add a switch or a variable for it.

## 6. Shadow

Do not edit any existing workflow file. For each workflow with chosen jobs, add one new file beside it: `ci.yml` gets `ci.trunk-shadow.yml`.

```yaml theme={"system"}
# .github/workflows/ci.yml, unchanged
name: CI
on:
  pull_request:
  push:
    branches: [main]
jobs:
  unit-tests:
    name: Unit tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - run: make test
```

```yaml theme={"system"}
# .github/workflows/ci.trunk-shadow.yml, new
name: CI (Trunk shadow)
on:
  pull_request:
  push:
    branches: [main]
jobs:
  unit-tests:
    name: Unit tests (Trunk shadow)
    runs-on: trunk=${{ github.run_id }}-${{ github.run_attempt }}
    continue-on-error: true
    steps:
      - uses: actions/checkout@v7
      - run: make test
```

Start from a copy of the original file, then make only these changes, so a `diff` of the two files shows the whole shadow:

1. **Workflow name.** Add `(Trunk shadow)` to `name:`. If the original has no `name:`, give the new file one.
2. **Same `on:`, without `workflow_dispatch`, `schedule` and `workflow_call`.** Both workflows then run on the same pushes and pull requests, and a scheduled job is not paid for twice. Keep one of those three triggers only when a chosen job runs on nothing else.
3. **Keep the chosen jobs and every job they need.** Delete the rest. A job cannot need a job in another workflow or read its artifacts, so a build that the chosen tests need comes along. Keep job keys the same, so `needs:` and outputs still line up.
4. **Job names.** Every job in the new file gets a `name:` that is the original's name, or its key when it has none, followed by `(Trunk shadow)`. Branch protection matches a check by its name alone, so a copy with the original's name would count as the required check.
5. **Runner.** Each kept job that can move (step 3) gets its Trunk label. A kept job that cannot move keeps its label.
6. **`continue-on-error: true`** on every job, so the shadow workflow never reports a failed run.
7. **Do the work once, not the side effects twice.**
   * Remove steps that deploy, publish, push, comment, label or notify, and jobs that do nothing else.
   * Remove steps that upload test results or coverage to a service, so no report counts a run twice.
   * Remove a job that reports for other jobs (a fan-in or "all checks passed" job).
   * If a `concurrency` group does not include `github.workflow`, add `-trunk-shadow` to it, or the two workflows cancel each other.
   * Give every job a `timeout-minutes` if it has none.
8. **A matrix keeps only the rows that move.** Drop the macOS, Windows and ARM rows.
9. **A job that calls a reusable workflow** (`uses: ./.github/workflows/build.yml`): copy the called file to `build.trunk-shadow.yml` with the same changes, and call that copy from the shadow.

Do not add the shadow jobs to branch protection, and never change branch protection yourself.

## 7. What can differ on a Trunk runner

Read this before you check the pull request's run, and use it to explain a failure.

* **Tools.** The docs do not list what the default Trunk runner image holds. A job that uses a tool GitHub's image preinstalls, without a setup step, can fail with "command not found". Fix it with a setup action or an install step in that job. A [template](https://docs.trunk.io/runners/actions/templates.md) can hold the tool later, which the user builds in the Trunk app.
* **Cache.** `actions/cache` reads and writes Trunk's shared cache, which starts empty. The first runs are slower than the ones after. Do not compare timings from a cold cache. See [Caching](https://docs.trunk.io/runners/cache/index.md).
* **Memory.** A label names only a size, so the job gets that size's standard memory, which can be less than its runner had (GitHub's larger runners have 4 GiB for each CPU). Only for a job that fails for memory, add `..memory=high` to its label and keep its size, and list it in the pull request. Leave every other job's memory out.
* **Queueing.** The organization has a limit on CPUs in use at once. At the limit, new jobs wait and then start. See [Quota and runner priority](https://docs.trunk.io/runners/settings/limits-and-priority.md).

## 8. Check your work, then open the pull request

Check every edited workflow before you commit:

1. Every Trunk label starts with `trunk=${{ github.run_id }}-${{ github.run_attempt }}`, or builds the same text with `format`.
2. The only option is `size`, with a value the docs list. No label sets `memory`, except a job that failed for memory (step 7).
3. No `runs-on` holds a Trunk label beside another label.
4. For a replace, every job name is the same as before your edits. For a shadow, `git diff` shows no change to any existing file.
5. For a shadow: each new file has the original's `on:` without the `workflow_dispatch`, `schedule` and `workflow_call` triggers that step 6 removes, every job has `continue-on-error: true` and a name ending in `(Trunk shadow)`, and every `needs:` names a job in the same file.
6. The file is valid. Run `actionlint` if it is installed.

Create a branch, commit and open a pull request titled "Move CI jobs to Trunk Runners", or "Shadow CI jobs on Trunk Runners". In the description, give:

* A table of the jobs moved or copied: the old label and the new one.
* The jobs left alone, with the reason for each.
* For a shadow: the files you added, what you removed from each, that deleting them removes the shadow, and that the cost of those jobs is paid twice until the cutover.
* For a replace: that reverting the pull request puts every job back on its old runner.
* That the pull request must not merge until its Trunk jobs have started and finished.

Then watch the pull request's own CI run. It uses the edited workflows, so it is the test.

* **Every Trunk job should start within a few minutes.** If one is still queued after ten, the label is wrong or the access in step 1 is not in place. Check the label against step 4 first. If it is right, cancel the run (`gh run cancel`), so no check stays pending, and tell the user which access item to confirm.
* **A Trunk job that fails where the original passes** is a difference from step 7. Fix it in the job, or take that job out of the pull request and list it.
* **Workflows that the pull request does not run** (`push` to the default branch, `schedule`, `workflow_dispatch`, `pull_request_target`) are not tested by it. List them, and tell the user to watch their first run after the merge.

## 9. Report

Tell the user what you set up, with the pull request link, and what is left for them:

1. **Confirm the access items** from step 1 that are still open.
2. **Merge when the Trunk jobs are green.**
3. **Watch the jobs** on [Runners → Instances](https://app.trunk.io/runners/instances).
4. **For a replace:** the workflows whose first run to watch. Reverting the pull request undoes the move.
5. **For a shadow:** come back after a week, or about twenty runs of each job, and ask you to compare and cut over (below).

Suggest at most two next steps that fit the repository:

* [Priority branches](https://docs.trunk.io/runners/settings/limits-and-priority.md#priority-branches) for the default branch and merge queue branches, so they start first when CI is busy.
* A [template](https://docs.trunk.io/runners/actions/templates.md) for a job that spends minutes installing tools.
* [Runners → Recommendations](https://app.trunk.io/runners/recommendations) once jobs have run for a few days: it lists a machine size for each job from what the job used.
* [Cache settings](https://docs.trunk.io/runners/cache/settings.md) to turn on sccache for Rust or the Nix cache, which are off by default.
* [Dynamic CI](https://docs.trunk.io/dynamic-ci.md) to skip the jobs a change cannot affect.

## Compare and cut over a shadow

When the repository already has `*.trunk-shadow.yml` workflows, the user wants the comparison, the cutover, or both.

### Compare

Read the last runs of each workflow and of its shadow, on the default branch and on pull requests (`gh run list --workflow`, then `gh api repos/{owner}/{repo}/actions/runs/{run_id}/jobs`). Pair the runs by commit SHA and the jobs by name, without the `(Trunk shadow)` ending. For each pair of jobs, leave out the shadow job's first runs, which had a cold cache, and report:

* **Run time:** `completed_at` minus `started_at`, as a median and a 90th percentile.
* **Wait for a runner:** `started_at` minus `created_at`.
* **Result:** the runs where one job passed and the other failed, with the failing step. A shadow job that fails where the original passes must be fixed before the cutover. A shadow job that passes where the original fails is often a flaky test, so say so and do not count it for Trunk.
* **Cost:** the shadow job's minutes multiplied by its machine's price on [Pricing](https://docs.trunk.io/runners/pricing.md). Ask the user what they pay per minute today, and do not guess it.

Give the numbers in one table and say plainly which jobs are ready, which are not, and why.

### Cut over

For each job that is ready, in one pull request titled "Move CI jobs to Trunk Runners":

1. Put the shadow job's `runs-on` value on the original job, as a replace (step 5).
2. Carry over any fix you made in the shadow to make it pass, such as an install step.
3. Delete the job from the shadow file, and delete the file when no job is left.

Leave the shadow jobs that are not ready, and list them. Then follow step 8 from the checks on.

## If the repository already uses Trunk Runners

If some jobs already have a `trunk=` label and there are no `*.trunk-shadow.yml` workflows, do not touch those jobs. Offer the remaining jobs, from step 1.

## Help

* [Trunk Runners](https://docs.trunk.io/runners.md)
* [Get started](https://docs.trunk.io/runners/getting-started.md)
* [The runs-on label](https://docs.trunk.io/runners/actions/runs-on.md)
* [Pricing](https://docs.trunk.io/runners/pricing.md)
* [support@trunk.io](mailto:support@trunk.io) and [Trunk on Slack](https://slack.trunk.io)
