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

# Run CI jobs on fresh machines

> Run your GitHub Actions jobs on InstaBox machines, a fresh one for each job, or run one test command on InstaBox from any CI.

InstaBox CI runs your GitHub Actions jobs on InstaBox machines. You change one line of a workflow,
and each job then gets a fresh machine of its own, which is deleted when the job ends.

> [card] [Quick start](https://instabox.sh/docs/use-cases/ci/quickstart.md)
>
> Connect GitHub, change `runs-on`, and see your first job run.

> [card] [Advanced: custom setup](https://instabox.sh/docs/use-cases/ci/custom-setup.md)
>
> Start every job with your toolchain, caches, and images already in place.

> [card] [Faster dependency installs](https://instabox.sh/docs/use-cases/ci/dependencies.md)
>
> Keep npm, pip, cargo, and Go packages between jobs with actions/cache or a snapshot.

## Why

* **A whole machine for each job.** The job has root on an Ubuntu 24.04 machine with the tools of
  GitHub's `ubuntu-24.04` image, so Docker works as it does on a GitHub-hosted runner.
* **Isolation.** A job never sees what another job left behind, because its machine is new and is
  deleted afterwards.
* **Bigger machines.** A job can run on up to 32 vCPUs and 64 GiB of memory, set by its label.
* **No GitHub Actions minutes.** The job runs on InstaBox, so it uses none of your minutes.

## How it works

You install the instabox GitHub App on your account or organization and set a job's `runs-on` to an
InstaBox label, such as `instabox-medium`. When GitHub queues that job, InstaBox creates a machine
from the `ci` template, registers it as a runner for that one job, and GitHub runs the job on it.
When the job ends, InstaBox deletes the machine.

## Cost

A job's machine is billed like any machine of its size, by the second, from its create to its
delete, and it counts toward your plan's machine limit. See [Pricing](https://instabox.sh/docs/account/pricing.md).

## Choose a machine size

The label in `runs-on` sets the size of the job's machine, and your plan decides which labels you
can use. The free plan runs `instabox-medium` only.

| Label | Machine | Plans |
| - | - | - |
| `instabox-small` | 2 vCPU, 4 GiB | Pro, Builder, Team |
| `instabox-medium` | 4 vCPU, 8 GiB | Free, Pro, Builder, Team |
| `instabox-large` | 8 vCPU, 16 GiB | Pro, Builder, Team |
| `instabox-xlarge` | 16 vCPU, 32 GiB | Builder, Team |
| `instabox-2xlarge` | 32 vCPU, 64 GiB | Team |

## Check what the machine has installed

The image is built from GitHub's runner-images release `ubuntu24/20261026.354`, so its tools and
versions are the ones in that release's
[Ubuntu 24.04 software list](https://github.com/actions/runner-images/blob/ubuntu24/20261026.354/images/ubuntu/Ubuntu2404-Readme.md).
A job can read the release in `$ImageVersion`. To print what the job's machine has, run this
command in a step of the job.

```bash theme={null}
/usr/local/lib/instabox/ci/software-list
```

> [!NOTE]
>
> Not installed: Haskell, Swift, Julia, CodeQL, Edge, and Homebrew. The Android SDK is a trimmed one,
> with a single NDK (27).

## Start jobs from a snapshot

A job can start from a snapshot of your own instead of a fresh machine, so your repository,
toolchain, and package caches are already there when the job begins. You set a machine up once,
save it as a snapshot, and name the snapshot in `runs-on`, as in
`runs-on: instabox-medium-snapshot-acme-warm`. [Advanced: custom setup](https://instabox.sh/docs/use-cases/ci/custom-setup.md)
has the steps and examples.

### When a job that names a snapshot is refused

A job is refused, with the reason in `instabox ci`, when the snapshot is not in the workspace
that the GitHub App is linked to, when it is still saving or failed, or when it was not saved from
a `ci` machine. A refused job never falls back to a fresh machine.

Snapshots work in private repositories only, and only with **Run workflows from fork pull
requests** turned off in the repository's **Settings > Actions > General**. In a public repository,
or in one that runs workflows from forks, jobs that name a snapshot are refused, because a fork's
workflow could name the snapshot too. If GitHub does not answer InstaBox's check, the job waits and
is tried again.

## Without the GitHub App

Your tests can also run on InstaBox from any CI, with no GitHub App: a step calls the CLI, which
runs one command on a machine and deletes the machine afterwards.

| | `runs-on: instabox-medium` (recommended) | The CLI from any CI |
| - | - | - |
| What runs on InstaBox | Each job, on a fresh machine of its own | One command per step |
| Setup | Install the GitHub App, change `runs-on` | An API key as a CI secret |
| Works with | GitHub Actions | Any CI |
| GitHub Actions minutes | None | The job's runner uses them |

## Run the CLI from any CI

This path works in any CI and needs no GitHub App. A step of your pipeline creates a machine,
uploads the checkout, runs one command, and deletes the machine. The example below is a GitHub
Actions workflow, and the same command works in a step of another CI.

**1. Store an API key as a CI secret**

The CLI in your pipeline signs in with an API key, so create one and store it as a secret of
your CI. This command creates a key that expires in 90 days and passes it to `gh`, which saves
it as the repository secret `INSTABOX_API_KEY`.

```bash theme={null}
instabox keys create --name github-ci --expires-in-days 90 --json \
  | jq -r .key \
  | gh secret set INSTABOX_API_KEY
```

The key goes straight into the secret and is not printed.

**2. Run the tests**

Add a job that installs the CLI and runs your tests with `instabox run`. In this workflow,
`npm ci && npm test` stands for your own test command.

```yaml theme={null}
jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      INSTABOX_API_KEY: ${{ secrets.INSTABOX_API_KEY }}
    steps:
      - uses: actions/checkout@v4
      - name: Install the instabox CLI
        run: npm install -g instabox
      - name: Run the tests
        run: |
          instabox run --push . --timeout 10m -e CI=1 -- \
            'npm ci && npm test'
```

The step's log shows the push, the command's output, and the machine's deletion. The step
fails when the command fails, and the command can run for 10 minutes at most.

### Pass secrets to the command

When your tests need a secret, pass it to the command as a variable with `-e NAME="$NAME"`. Pull
requests from forks get no secrets, so the step cannot run there.

> [card] [API keys](https://instabox.sh/docs/security/api-keys.md)
>
> Scopes and expiry for the key your CI uses.

> [card] [CLI reference](https://instabox.sh/docs/reference/cli.md)
>
> `instabox run` and its exit codes.
