Use Brev in CI/CD
A pipeline can create a Brev instance, run a workload on it, and delete it when the job ends. Any CI system that runs shell commands and stores secrets can drive the Brev CLI.
Prerequisites
- An API key with Read & Write access for the organization the pipeline provisions into
- Available credits in that organization
Brev API keys are Personal API keys, not machine accounts. A key acts on behalf of the user who created it, so the pipeline runs with that user’s permissions and stops working if they lose access to the organization. Create the key from an account that will remain in the organization.
Set Up the CLI in a Pipeline
Your pipeline installs the CLI, signs in with the API key, and configures SSH:
brev login --api-key selects the key’s organization automatically. Run brev refresh after signing in to set up your SSH config, which the pipeline needs to reach the instance.
Once signed in, your pipeline can run any Brev command. See CLI Overview for the full command set.
Store the Key as a CI Secret
Store the key in your CI system’s secret store, never in the pipeline definition. Each system names this differently: GitHub Actions calls it a repository secret, GitLab CI calls it a CI/CD variable, and Jenkins calls it a credential.
Example: GitHub Actions
Set the hardware selection on brev create and the workload command to the values your project requires. See Instance Creation for the available hardware flags.
Retain if: always() on the delete step. Without it, a failed run leaves the instance provisioned and billing.