Run the CLI in CI/CD
Use this guide when you want to run the shipped chainabit commands from a non-interactive job.
Install the CLI
npm install -g @chainabit/cliProvide Credentials Safely
For CI jobs, prefer a time-bounded developer token or an already-issued access token instead of typing passwords into the command line.
Option 1: Reuse an Existing Token
Configure CHAINABIT_TOKEN in the CI secret store, then check the resolved identity:
chainabit auth whoami --jsonCHAINABIT_TOKEN works with any API address. A saved sign-in is sent only to the API address it was created on, so a job that targets a different API address needs its own token.
Option 2: Log In with a Developer Token
chainabit auth login \
--token-env CHAINABIT_DEVELOPER_TOKENThe CLI authenticates with the developer token and keeps it in your configuration for later commands.
Verify the Workspace Context
Use --json so the pipeline can parse structured output.
chainabit auth whoami --json
chainabit workspace current --jsonExpected result: authentication succeeds for the intended account and the resolved workspace ID matches your job. workspace current reads local context; use workspace list --json when you also need to check server-side workspace access. Do not hardcode example user IDs or expiry timestamps into a pipeline assertion.
Run Real Commands
Once authenticated, you can inspect workspace state, connectors, and AI metadata from the job:
chainabit chain list --json
chainabit connectors list --json
chainabit ai models --jsonRead the returned catalog for your account rather than assuming a connector is installed, authorized, or available because it appears in a sample. Each command still requires its own scope and resource access.
Example GitHub Actions Workflow
name: Chainabit check
on: [push]
jobs:
verify:
runs-on: ubuntu-latest
env:
CHAINABIT_BASE_URL: https://api.chainabit.com/api/v1
CHAINABIT_WORKSPACE_ID: ${{ secrets.CHAINABIT_WORKSPACE_ID }}
CHAINABIT_DEVELOPER_TOKEN: ${{ secrets.CHAINABIT_DEVELOPER_TOKEN }}
steps:
- uses: actions/checkout@v4
- run: npm install -g @chainabit/cli
- run: chainabit auth login --token-env CHAINABIT_DEVELOPER_TOKEN
- run: chainabit auth whoami --json
- run: chainabit workspace current --json
- run: chainabit connectors list --json
- run: chainabit ai models --jsonCreating the Token
Create the CI token from a trusted interactive session:
chainabit auth keys create "github-actions" --ttl 90 --scope execution:runComplete any password or authenticator verification prompted by the CLI. Create the key before starting the CI job; unattended jobs should use the issued key from the secret store.
Add --scope wallet:read if the job needs wallet visibility, or --account <account-uuid> if the token must stay bound to one account.
Handle failures deliberately
Fail the job when authentication or a required command returns a nonzero status. Keep credentials in the CI secret store, avoid echoing them, and do not upload the CLI's local config as a build artifact. Use a dedicated CHAINABIT_CONFIG_DIR if the runner keeps state between jobs.
Before adding mutations, confirm the selected workspace and the required token scopes. If a mutation times out, inspect the resulting resource before retrying: another command invocation starts a new operation.
When to Use Another Page
- Use CLI Command Reference for the full command surface.
- Use CLI Configuration for local config files and environment variables.
- Use Connectors CLI Reference when the job manages connector instances or credentials.