# Groundbox first or GitHub first

Each job can name two runners: a Groundbox runner and a GitHub-hosted one. The Actions variable `CI_RUNNER` picks between them. When it is `groundbox`, the job runs on Groundbox. Otherwise, or when it isn't set, it runs on GitHub.

```
jobs:
  test:
    runs-on: ${{ vars.CI_RUNNER == 'groundbox' && 'groundbox-auto-test-ubuntu-2604' || 'ubuntu-latest' }}
```

```
groundbox migrate --first groundbox --dry-run
groundbox migrate --first groundbox
```

The same change works for both choices below. Groundbox sets the variable; only its value changes, never your workflows. Pick one under Repos and runners, GitHub accounts, for each account. It can open the pull request with this change for each repo.

`--first groundbox` also gives jobs already on Groundbox labels GitHub's runner of the same Ubuntu release as the fallback: `ubuntu-24.04`, or `ubuntu-26.04` for a label ending in `-ubuntu-2604`. `--first github` leaves those as they are. Commit the files yourself: the CLI writes them and runs no git command.

## From the CLI, an agent or the API

An agent can do all of it with an API key. The dashboard opens the workflow pull request as you, which a key can't do, so an agent rewrites the files in the repo with `groundbox migrate --first groundbox` and commits them itself. Then it sets the mode.

```
groundbox ci first                                    # each GitHub account: its mode and where jobs run now
groundbox ci first groundbox --account acme           # or github, or off
groundbox ci first switch now --account acme          # GitHub first only; switch back with: switch back
```

- API: `GET /v1/ci/github-first` needs `ci:read`. `PUT /v1/ci/github-first` (installation_id, mode) and `POST /v1/ci/github-first/switch` (installation_id, to) need `ci:write`. A signed-in person must be a team owner or admin.
- SDKs: `get_ci_first_mode`, `set_ci_first_mode` and `switch_ci_first`, in TypeScript and Python. They take the GitHub login as `account`.
- MCP: `ci_first_mode_info` reads each account's mode, and `ci_first_mode` takes `action` set, switch_now or switch_back; it needs a key with `ci:write`, which the key made by the MCP sign-in does not have ([which tools need which key](https://groundbox.dev/docs/mcp#tools)). The `ci` tool's `convert` action with mode `github-first` returns the rewritten files.

## Groundbox first

Pick this to try Groundbox with no risk. Every job runs on Groundbox from the start, on the free plan's minutes and credit. CI never stops.

- When your team can't run jobs on Groundbox, Groundbox sets `CI_RUNNER` to `github` and new jobs run on GitHub's runners. That is when the free minutes are used and there is no credit, card or plan, or the team is at its spend cap.
- When you add a card, top up, start the plan, or on the 1st when the free minutes reset, it goes back to `groundbox`.
- It goes by your Groundbox usage, which we know exactly. It reads nothing from GitHub's billing.
- Jobs already queued for a Groundbox runner when it switches stay queued: GitHub doesn't move them. They start when your team can run again. The dashboard shows how many.
- You get one email when your jobs move to GitHub and one when they come back, at most once a month each.
- New sign-ups get this by default when the onboarding opens the pull request. Teams already on plain Groundbox labels can pick it.

## GitHub first

Pick this if you already pay for GitHub's included Actions minutes. Jobs run on GitHub while they last, then on Groundbox until GitHub's month resets on the 1st.

- For an organization, Groundbox reads GitHub's billing report every hour. When GitHub starts billing for Actions, or 95% of the included amount is used when it is known, Groundbox sets `CI_RUNNER` for the org's private repos. New jobs run on Groundbox. Jobs already running finish where they are.
- On the 1st, Groundbox deletes the variable and jobs run on GitHub again. You get an email each time it switches.
- GitHub doesn't show a personal account's billing to apps. There, use **Switch now**; it switches back on the 1st.
- Public repos stay on GitHub: their minutes are free there.
- If your team has no Groundbox credit left, nothing switches and you get an email.

## When GitHub's runners are stuck

GitHub first can also move jobs when GitHub's own runners stop picking them up, such as a macOS pool with no free machines. Turn it on with a limit in minutes. It is off unless you set it.

```
groundbox ci first github --queue-stall 10 --account acme
groundbox ci first github --queue-stall off --account acme
```

- Groundbox sees every job queued on a GitHub-hosted runner of your private repos (Linux, Linux arm64, macOS and Windows). When one has waited longer than your limit, Groundbox sets `CI_RUNNER` and new jobs run on Groundbox. It checks every 5 minutes.
- It works on personal accounts too: it reads no billing report.
- Only repos set up for GitHub first count: a workflow on the default branch reads `vars.CI_RUNNER` (what `groundbox migrate --first github` writes). A job stuck in any other repo can't move, so it switches nothing. Before switching, Groundbox asks GitHub that the job is really still queued, and jobs queued more than 24 hours ago never count (GitHub cancels them).
- Jobs already stuck in GitHub's queue stay there, because GitHub doesn't move a queued job. Cancel and re-run one if you want it to start now.
- New jobs go back to GitHub once nothing is stuck there and at least 30 minutes have passed since the switch, so a queue that is slow on and off doesn't flip back and forth. If GitHub's included minutes ran out in the meantime, they stay on Groundbox, as before.
- A macOS, Windows or arm64 job only counts when your team can run that platform on Groundbox. If your team has no credit left, nothing switches.
- You get an email when the jobs move and when they come back, at most one of each a day. After a **Switch back** by hand, nothing switches again until the 1st.
- From the API: `queue_stall_minutes` (1 to 360, or null for off) on `PUT /v1/ci/github-first`, and `github_queue` (jobs waiting on GitHub now, and the longest wait) on `GET`. The SDKs' `set_ci_first_mode` and the MCP tool `ci_first_mode` take the same field.

## Permissions

- Both need the App's Variables permission (read and write) to set `CI_RUNNER`: on the organization, or on each repo of a personal account. GitHub first also needs Administration (read) on an organization, to read billing.
- The dashboard links to the page where an owner accepts them.
- macOS, Windows and Linux arm64 jobs switch the same way, to `groundbox-macos`, a `groundbox-windows` size or a `groundbox-<N>vcpu-arm` size, and fall back to their own GitHub label (`macos-latest`, `windows-latest`, `ubuntu-24.04-arm` for jobs already on Groundbox). Jobs that can't move (a list of labels, a matrix that mixes platforms, Windows on Arm) are left as they are, with a warning.
